boto3错误:botocore.exceptions.nocredentialserror:无法通过shell脚本找到凭据
当我从CLI(终端)跑步时,它可以通过SSO找到凭据并通过 例如:
2022-06-18 07:38:36,421 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2022-06-18 07:38:36,421 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2022-06-18 07:38:36,421 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: sso
2022-06-18 07:38:36,422 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/v2/2.7.8/dist/awscli/botocore/data/endpoints.json
2022-06-18 07:38:36,432 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x7fb797891040>
2022-06-18 07:38:36,433 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.ecr: calling handler <function add_generate_presigned_url at 0x7fb797909820>
当我通过Shell脚本运行相同的命令时,它找不到凭据:
2022-06-18 07:38:53,667 - MainThread - botocore.hooks - DEBUG - Event building-command-table.get-login-password: calling handler <function add_waiters at 0x7fa1820bf9d8>
2022-06-18 07:38:53,667 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2022-06-18 07:38:53,667 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: custom-process
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: config-file
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: ec2-credentials-file
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: boto-config
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: container-role
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: iam-role
这是命令:
aws ecr get-login-password --region xxx --profile xxx | docker login --username AWS --password-stdin xxxxxx.amazonaws.com
我是否缺少配置?
When I run from CLI(terminal) it works, it finds the credentials via sso and passes on
EX:
2022-06-18 07:38:36,421 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2022-06-18 07:38:36,421 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2022-06-18 07:38:36,421 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: sso
2022-06-18 07:38:36,422 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/local/aws-cli/v2/2.7.8/dist/awscli/botocore/data/endpoints.json
2022-06-18 07:38:36,432 - MainThread - botocore.hooks - DEBUG - Event choose-service-name: calling handler <function handle_service_name_alias at 0x7fb797891040>
2022-06-18 07:38:36,433 - MainThread - botocore.hooks - DEBUG - Event creating-client-class.ecr: calling handler <function add_generate_presigned_url at 0x7fb797909820>
When I run the same command via a shell script it doesn't find the credentials:
2022-06-18 07:38:53,667 - MainThread - botocore.hooks - DEBUG - Event building-command-table.get-login-password: calling handler <function add_waiters at 0x7fa1820bf9d8>
2022-06-18 07:38:53,667 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role
2022-06-18 07:38:53,667 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: assume-role-with-web-identity
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: custom-process
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: config-file
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: ec2-credentials-file
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: boto-config
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: container-role
2022-06-18 07:38:53,668 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: iam-role
This is the command:
aws ecr get-login-password --region xxx --profile xxx | docker login --username AWS --password-stdin xxxxxx.amazonaws.com
Am I missing a configuration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经用鲍泽命令解决了这个问题:
这
也对我有很大帮助:
https://github.com/aws/aws/aws/aws-cli/issues/4982
I've solved the issue with the bellow commands:
and
This also helped me a lot:
https://github.com/aws/aws-cli/issues/4982