"aws configure" simple creates the credential file for you on your workstation or server in the file %USERPROFILE%\.aws\credentials. You type the credentials in, it puts them into the file on the local server. As far as I know it doesn't do anything else with the credentials.
You can edit it directly to do exactly the same thing. It's a regular file, holding AWS access key and secret keys.
In terms of security, having your credentials stored in a file on a workstation / server unencrypted isn't ideal. If your computer gets a virus or ransomware they could be lost or stolen. If this ever happens you should remove those keys in the AWS console and issue new keys once your machine is sufficiently secure again.
IMHO the risk is worthwhile if you need to use the AWS CLI, so long as your machine has good security practices. Basics like a firewall, virus / malware scanner, etc.
Answer from Tim on serverfault.comVideos
"aws configure" simple creates the credential file for you on your workstation or server in the file %USERPROFILE%\.aws\credentials. You type the credentials in, it puts them into the file on the local server. As far as I know it doesn't do anything else with the credentials.
You can edit it directly to do exactly the same thing. It's a regular file, holding AWS access key and secret keys.
In terms of security, having your credentials stored in a file on a workstation / server unencrypted isn't ideal. If your computer gets a virus or ransomware they could be lost or stolen. If this ever happens you should remove those keys in the AWS console and issue new keys once your machine is sufficiently secure again.
IMHO the risk is worthwhile if you need to use the AWS CLI, so long as your machine has good security practices. Basics like a firewall, virus / malware scanner, etc.
aws configure actually isn't required when using non-default locations for credentials and configurations files. If the file locations for these files are set correctly in the environment variables, AWS_SHARED_CREDENTIALS_FILE and AWS_CONFIG_FILE respectively, then the aws cli knows where to look for the credentials and configuration. I therefore do not need to worry about any security issues relating to aws configure.
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.
One liner
aws configure set aws_access_key_id "AKIAI44QH8DHBEXAMPLE" --profile user2 && aws configure set aws_secret_access_key "je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY" --profile user2 && aws configure set region "us-east-1" --profile user2 && aws configure set output "text" --profile user2
Note: setting region is optional (also never set it with an empty string if you don't have any region, or it will be buggy); as well as the user profile, if you don't set it it will go under default settings.
Better practice with Secrets
Use secrets, then use associated environment variables:
aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile user2 && aws configure set aws_secret_access_key "$AWS_ACCESS_KEY_SECRET" --profile user2 && aws configure set region "$AWS_REGION" --profile user2 && aws configure set output "text" --profile user2
To know more
- Run
aws configure set helpto get command line options. - Documentation for aws configure set.
- Documentation for secrets: Docker, Kubernetes, GitLab.