manuelBetancurt
manuelBetancurt

Reputation: 16138

AWS CLI docker: parameters are not formatted correctly

I need to make some work with docker and AWS.

when I try to run

$ docker run --rm -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY grycap/aws-cli ec2 describe-instances

I get:

An error occurred (AuthFailure) when calling the DescribeInstances operation: Authorization header or parameters are not formatted correctly.

But my $aws configure is already done; when I run

$aws configure list

I get:

Name                    Value             Type    Location
----                    -----             ----    --------
profile                <not set>             None    None
access_key     ****************3Y7Q shared-credentials-file
secret_key     ****************yCIY shared-credentials-file
region           ap-southeast-2      config-file    ~/.aws/config

Edit: when I try

echo $AWS_ACCESS_KEY_ID

the response is an empty line...

Upvotes: 1

Views: 2562

Answers (1)

chintan thakar
chintan thakar

Reputation: 1500

Here is the complete solutions.

export AWS_ACCESS_KEY_ID=<Your-Actual-key> export AWS_SECRET_ACCESS_KEY=<Your-Actual-key> export AWS_DEFAULT_REGION=<Your-Actual-Region>

And than run command below :

docker run --rm -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY grycap/aws-cli ec2 describe-instances

Alternatively You can put all these three in ~/.bash_profile

AWS_ACCESS_KEY_ID=<Your-Actual-key>; export AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=<Your-Actual-key> ; export AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION=<Your-Actual-Region> ;export AWS_DEFAULT_REGION

source ~/.bash_profile and than run command :

docker run --rm -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY grycap/aws-cli ec2 describe-instances

hope this will help. Thank You!

Upvotes: 2

Related Questions