Can I specify a default AWS configuration profile?

爷,独闯天下 提交于 2019-12-23 09:37:35

问题


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.


回答1:


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."



来源:https://stackoverflow.com/questions/35660499/can-i-specify-a-default-aws-configuration-profile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!