AWS - Named Profiles
Updated at 2017-10-20 15:24
If you are working with multiple AWS accounts using the same machine, use AWS CLI named profiles.
~/.aws/credentials
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[ruksi]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
~/.aws/config
[default]
region=us-west-2
output=json
[profile ruksi]
region=us-east-1
output=text
Using profiles:
# Using profile for a single command.
aws ec2 describe-instances --profile ruksi
# Using profile for all the following shell commands or in script.
export AWS_PROFILE=ruksi
Gain information about the profiles:
# Tells the default "profile".
aws iam get-user
# Checking if the profile can be found by AWS CLI.
aws iam get-login-profile --user-name=ruksi