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.

aws_access_key_id={YOUR_ACCESS_KEY_ID}
aws_secret_access_key={YOUR_SECRET_ACCESS_KEY}

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,300 points
34 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+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.

[default]
aws_access_key_id = ACCESS_KEY
aws_secret_access_key = SECRET_KEY
aws_session_token = TOKEN
[Alice]
aws_access_key_id = Alice_access_key_ID
aws_secret_access_key = Alice_secret_access_key
[Bob]
aws_access_key_id = Bob_access_key_ID
aws_secret_access_key = Bob_secret_access_key

answered Aug 24, 2018 by Priyaj
• 56,140 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
93 views
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,140 points
222 views
+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,140 points
76 views
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  https://aws.amazon.com/certificate-manager/faqs/ You can't install the certificates ...READ MORE

answered Jul 19, 2018 in AWS by Priyaj
• 56,140 points
34 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.