在我的开发环境中,我定期在多个AWS访问密钥之间切换.因此,在我的~/.aws/credentials文件中,我有几个配置文件.然后,通过指定--profile <name>标志,可以将这些配置文件与aws-cli一起使用.
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.
我开发了几个使用Ruby AWS SDK的应用程序.它们被设置为从~/.aws/credentials文件读取凭据(默认情况下,SDK会执行此操作,请参阅此配置文章).
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).
问题在于,SDK始终从default配置文件读取.我希望能够将其配置为从其他一些配置文件中读取.这可能吗?
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>如配置AWS Command Line Interface ,但似乎仅适用于aws-cli,不适用于SDK.
as outlined in configuring the AWS Command Line Interface but it seems that only works with the aws-cli and not with the SDK.
推荐答案对于SDK:
通过将AWS_PROFILE环境变量设置为您使用的配置文件 要使用.
By setting the AWS_PROFILE environment variable to the profile you want to use.
对于CLI:
来自:一种用于管理AWS开发工具包中凭证的新型标准化方法
"AWS_DEFAULT_PROFILE对于AWS CLI是正确的.AWSCLI尊重 AWS_PROFILE(如果已设置),但AWS_DEFAULT_PROFILE优先."
"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."
更多推荐
我可以指定默认的AWS配置配置文件吗?
发布评论