Using multiple AWS accounts from the command line is natively handled with profiles in the AWS CLI.
Using aws configure
Using the aws configure
command, multiple profiles can be configured.
|
|
Then, the --profile account1
option may be used with future commands.
|
|
Or an environment variable may be set.
|
|
Note: If the profile is named --profile default
, it will represent the default profile when no --profile
argument is provided.
Manually setting credentials
The ~/.aws/credentials
and ~/.aws/config
files can be modified directly.
- Add the credentials to the
~/.aws/credentials
file
|
|
- Add the profile to the
~/.aws/config
file
|
|
- Use the
--profile
argument or set theAWS_PROFILE
environment variable.
|
|
OR
|
|