How to switch between multiple accounts with AWS SDK

0 votes

Im currently using the credential file (~/.aws/credentials) to initialize the SDK.

Credential File format.


My requirement is to switch between multiple aws accounts. I'm currently trying to resolve this by overwriting the file with new credentials and re initialize the sdk. Is there any other efficient workaround to resolve this ? Thanks in Advance.

Aug 24, 2018 in AWS by bug_seeker
• 15,350 points

1 answer to this question.

+1 vote

You can define multiple profiles in ~/.aws/credentials and refer to the profile in your SDK initialization. See: A New and Standardized Way to Manage Credentials in the AWS SDKs which also shows examples for each language.

aws_access_key_id = ACCESS_KEY
aws_secret_access_key = SECRET_KEY
aws_session_token = TOKEN
aws_access_key_id = Alice_access_key_ID
aws_secret_access_key = Alice_secret_access_key
aws_access_key_id = Bob_access_key_ID
aws_secret_access_key = Bob_secret_access_key

answered Aug 24, 2018 by Priyaj
• 56,540 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

How to use AWS CLI with Elastic Beanstalk?

You have to create a source bundle ...READ MORE

answered Sep 28, 2018 in AWS by Archana
• 4,090 points
0 votes
1 answer

How to update shadow with Single AWS IOT rule

You need to use + instead of ...READ MORE

answered Oct 15, 2018 in AWS by Priyaj
• 56,540 points
+3 votes
1 answer

How to download aws sdk in my eclipse?

To use AWS SDK simply follow the ...READ MORE

answered Dec 11, 2018 in AWS by Priyaj
• 56,540 points
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to add SSL certificate to AWS EC2 with the help of new AWS Certificate Manager service

refer this link You can't install the certificates ...READ MORE

answered Jul 19, 2018 in AWS by Priyaj
• 56,540 points