我可以指定默认的AWS配置配置文件吗?

编程入门 行业动态 更新时间:2024-10-19 00:20:29
本文介绍了我可以指定默认的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开发工具包中凭证的新型标准化方法

"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配置配置文件吗?

本文发布于:2023-11-28 07:13:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641428.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:配置文件   AWS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!