Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Configure Bash One Liner

Can anybody tell me how to automate the aws configure in bash with a one liner?

Example:

$ aws configure --profile user2 AWS Access Key ID [None]: AKIAI44QH8DHBEXAMPLE AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY Default region name [None]: us-east-1 Default output format [None]: text 

Application: I want to automate this inside a Docker Entrypoint!

like image 692
blacklabelops Avatar asked Jan 17 '16 14:01

blacklabelops


2 Answers

If you run aws configure set help you will see that you can supply settings individually on the command line and they will be written to the relevant credentials or config file. For example:

aws configure set aws_access_key_id AKIAI44QH8DHBEXAMPLE

You can also run this interactively to modify the default credentials:

aws configure

Or run it interactively to create/modify a named profile:

aws configure --profile qa

Note: with the first technique above, whatever command you type will appear in your history and this is not a good thing for passwords, secret keys etc. So in that case, use an alternative that does not cause the secret parameter to be logged to history, or prevent the entire command being logged to history.

like image 64
jarmod Avatar answered Oct 02 '22 16:10

jarmod


For those inclined to use bash, the following works quite well and keeps secrets out of your scripts. In addition, it will also save your input to a named profile in one go.

printf "%s\n%s\nus-east-1\njson" "$KEY_ID" "$SECRET_KEY" | aws configure --profile my-profile 
like image 26
killthrush Avatar answered Oct 02 '22 16:10

killthrush