问题描述
如何通过在根凭据/配置文件中指向配置文件来从用户运行aws cli命令?
我设置了以下内容:
export AWS_CONfig_FILE=/root/.aws/config
export AWS_SHARED_CREDENTIALS_FILE=/root/.aws/credentials
我的凭据和配置文件如下:
# /root/.aws/config
[profile xaxa]
aws_access_key_id=xxx
aws_secret_access_key=xxx
region=ap-southeast-2
# /root/.aws/credentials
[profile xaxa]
aws_access_key_id=xxx
aws_secret_access_key=xxx
然后,我运行以下命令:
sudo aws --profile xaxa ecr get-login-password --debug
但它让我回来了
找不到配置文件(xaxa)
解决方法
您需要使用[]之间的完整个人资料名称。就您而言,以下方法应该有效:
sudo aws --profile 'profile xaxa' ecr get-login-password --debug