Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I specify a default AWS configuration profile?

In my development environment, I regularly switch between several AWS access keys. So in my ~/.aws/credentials file, I have several profiles. I can then use these profiles with aws-cli by specifying the --profile <name> flag.

I develop several apps that use the Ruby AWS SDK. They are setup to read credentials from the ~/.aws/credentials file (the SDK does this by default, see this configuration article).

The problem is that the SDK always reads from the default profile. I would like to be able to configure it to read from some of the other profiles. Is this possible?

I've tried setting the default profile in my environment with:

export AWS_DEFAULT_PROFILE=<profile name>

as outlined in configuring the AWS Command Line Interface but it seems that only works with the aws-cli and not with the SDK.

like image 508
Justin Howard Avatar asked Feb 26 '16 19:02

Justin Howard


1 Answers

For SDK:

By setting the AWS_PROFILE environment variable to the profile you want to use.

For CLI:

From: A New and Standardized Way to Manage Credentials in the AWS SDKs

"AWS_DEFAULT_PROFILE is correct for the AWS CLI. The AWS CLI respects AWS_PROFILE if it is set, but AWS_DEFAULT_PROFILE takes precedence."

like image 92
helloV Avatar answered Oct 15 '22 21:10

helloV