gpt4 book ai didi

amazon-web-services - "MissingRegion": could not find region configuration, 但我在 ~/.aws.config 中有它

转载 作者:数据小太阳 更新时间:2023-10-29 03:18:02 27 4
gpt4 key购买 nike

我的代码:

sess = session.Must(session.NewSessionWithOptions(session.Options{
Profile: "gms-ai",
}))

我的 ~/.aws/config:

[default]
output = json
region = us-east-1

[profile gms-ai]
output = json
region = us-east-2

但是例如,这是我的部署脚本中的工作片段:

AWS_PROFILE=gms-ai \
aws lambda update-function-code...

看起来 aws cli 确实读取了 region 但 AWS SDK 忽略了它?

最佳答案

这是预期的行为。看这里:

By default the SDK will only load the shared credentials file's (~/.aws/credentials) credentials values, and all other config is provided by the environment variables, SDK defaults, and user provided aws.Config values.

If the AWS_SDK_LOAD_CONFIG environment variable is set, or SharedConfigEnable option is used to create the Session the full shared config values will be loaded. This includes credentials, region, and support for assume role. In addition the Session will load its configuration from both the shared config file (~/.aws/config) and shared credentials file (~/.aws/credentials). Both files have the same format.

链接 here .

因此只需设置 AWS_SDK_LOAD_CONFIG 环境变量即可读取配置。

关于amazon-web-services - "MissingRegion": could not find region configuration, 但我在 ~/.aws.config 中有它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58069458/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com