我可以指定默认的AWS配置配置文件吗? [英] Can I specify a default AWS configuration profile?

查看:515
本文介绍了我可以指定默认的AWS配置配置文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的开发环境中,我定期在多个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_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配置配置文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆