配置 bash 脚本以将资源部署到指定的 AWS 区域时,区域被托管凭据覆盖,
Region being overridden by managed credentials when configuring bash script to deploy resources to specified AWS region,
我有一个 bash 脚本,我 运行 在 AWS EC2 实例上(运行s Cloud9 作为开发环境),用于 bootstrap AWS 资源环境(在这种情况下,我的沙箱)。我正在配置我想部署到的区域:
aws configure set region "ap-southeast-1"
REGION=$(aws configure get region)
echo $REGION
$REGION 变量的设置不正确。使用 set region ...
在 EC2 实例的 ~/.aws/config 文件中正确设置区域。我的 EC2 实例使用 AWS 托管凭证,这意味着我自己的本地 AWS 区域存储在 EC2 实例上的 ~/.aws/credentials
文件中,该文件覆盖了 config
文件,因此 aws configure get region
returns credentials
文件中指定的区域。使用托管凭据时,有没有办法在 AWS EC2 实例中设置和获取区域?
请查看 order of precedence 以设置 AWS 凭据。请注意 运行 aws configure
仅创建凭据文件,这是优先列表中的第 3 项。我建议使用环境变量,第二个优先项。
我有一个 bash 脚本,我 运行 在 AWS EC2 实例上(运行s Cloud9 作为开发环境),用于 bootstrap AWS 资源环境(在这种情况下,我的沙箱)。我正在配置我想部署到的区域:
aws configure set region "ap-southeast-1"
REGION=$(aws configure get region)
echo $REGION
$REGION 变量的设置不正确。使用 set region ...
在 EC2 实例的 ~/.aws/config 文件中正确设置区域。我的 EC2 实例使用 AWS 托管凭证,这意味着我自己的本地 AWS 区域存储在 EC2 实例上的 ~/.aws/credentials
文件中,该文件覆盖了 config
文件,因此 aws configure get region
returns credentials
文件中指定的区域。使用托管凭据时,有没有办法在 AWS EC2 实例中设置和获取区域?
请查看 order of precedence 以设置 AWS 凭据。请注意 运行 aws configure
仅创建凭据文件,这是优先列表中的第 3 项。我建议使用环境变量,第二个优先项。