AWS CLI docker: parameters are not formatted correctly


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...





can you share output of echo $AWS_ACCESS_KEY_ID from host machine ? is it showing your actual access_keys ?
– chintan thakar
Jul 3 at 6:01


echo $AWS_ACCESS_KEY_ID





It seems like you should use docker run -it -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION grycap/aws-cli ec2 describe-instances
– chintan thakar
Jul 3 at 6:03



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





hi @chintanthakar, thanks for the reply, trying echo, returns empty line
– MaKo
Jul 3 at 6:05





yes that's the reason you are getting Authentication error. you first have to export AWS_ACCESS_KEY_ID=<Your-Actual-key> and same for $AWS_SECRET_ACCESS_KEY, $AWS_DEFAULT_REGION than you have to run the 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 it will work definitely
– chintan thakar
Jul 3 at 6:07


export AWS_ACCESS_KEY_ID=<Your-Actual-key> and same for $AWS_SECRET_ACCESS_KEY, $AWS_DEFAULT_REGION


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




1 Answer
1



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>


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


~/.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 :


source ~/.bash_profile


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!






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages