本文介绍了错误:致命的NoCredentialProviders:链中没有有效的提供程序,原因是:EnvAccessKeyNotFound:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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

推荐答案

我的~/.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

这篇关于错误:致命的NoCredentialProviders:链中没有有效的提供程序,原因是:EnvAccessKeyNotFound:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 15:24