1

我正在使用aws-runas运行以下 aws-cli 命令:

aws-runas xxx-prod aws s3 ls

我收到以下错误:

FATAL NoCredentialProviders: no valid providers in chain caused by: EnvAccessKeyNotFound: 
failed to find credentials in the environment. SharedCredsLoad: failed to load profile, xxx- 
prod. EC2RoleRequestError: no EC2 instance role found caused by: RequestError: send request 
failed caused by: Get http://169.254.169.254/latest/meta-data/iam/security-credentials/: 
net/http: request canceled (Client.Timeout exceeded while awaiting headers)

我的~/.aws/credentials文件:

[default]
aws_access_key_id=ABC
aws_secret_access_key=XYZ

我的~/.aws/config文件:

[default]
region = us-east-1
output = json
[profile xxx-prod]
role_arn=arn:aws:iam::11111111:role/managed-role/AcctAdmin
mfa_serial =arn:aws:iam::2222222:mfa/abc@gmail.com
4

1 回答 1

1

我的~/.aws/config文件中缺少以下行:

source_profile=default

添加上面的解决了这个问题。

我完整的~/.aws/config文件:

[default]
region = us-east-1
output = json
[profile xxx-prod]
source_profile=default
role_arn=arn:aws:iam::11111111:role/managed-role/AcctAdmin
mfa_serial =arn:aws:iam::2222222:mfa/abc@gmail.com
于 2020-03-28T00:51:39.617 回答