amazon-ec2ec2-api-tools

How to configure Amazon EC2 command line interface?


I want to install Amazon Ec2 cli tools on a linux machine. I have configured java and have installed ec2 cli tools but I am getting the following error:

[root@ip-/]# ec2-describe-regions | sort Required option '-O, --aws-access-key KEY' missing (-h for usage)

Also please tell me how to set EC2_PRIVATE_KEY, EC2_CERT parameters. How to resolve this.


Solution

  • Option 1:

    Set it as environment variable. Perhaps, append the following to your ~/.bashrc

    export AWS_ACCESS_KEY=<your-aws-access-key-id>
    export AWS_SECRET_KEY=<your-aws-secret-key>
    

    If you do not want to do that, you may also type the above before you execute API commands.

    Option 2:

    Pass it with every command. Like this:

    <command> --aws-access-key <aws_access_key_id> --aws-secret-key <aws_secret_access_key> [other opts]
    

    for example:

    ec2-run-instances ami-5da964c3  --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY 
    

    You may also want to read the documentation: http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/command-reference.html