AWS Configuring Bash Single Insert

Can someone tell me how to automate aws configuration in bash with a single 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 the Docker entry point!

+5
source share
3 answers

If you run aws configure set help , you will see that you can specify the parameters separately on the command line, and they will be written to the appropriate credentials or configuration file. For instance:

aws configure set aws_access_key_id AKIAI44QH8DHBEXAMPLE

+10
source

If you want to automate, you should use the files, not the CLI. Your CLI writes only those files.

 ➜ cat ~/.aws/config [profile_1] output = json region = eu-west-1 [profile_2] output = json region = eu-west-1 ➜ cat ~/.aws/credentials [profile_1] aws_access_key_id = aws_secret_access_key = [profile_2] aws_access_key_id = aws_secret_access_key = 
+2
source

For those who are inclined to use bash, the following works quite well and keeps secrets from your scripts. In addition, it will also save your login to the named profile at a time.

 printf "%s\n%s\nus-east-1\njson" "$KEY_ID" "$SECRET_KEY" | aws configure --profile my-profile 
+2
source

Source: https://habr.com/ru/post/1240802/


All Articles