Boto3间歇性NoAuthHandlerFound错误

Boto3间歇性NoAuthHandlerFound错误

本文介绍了Boto3间歇性NoAuthHandlerFound错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试通过Boto3连接到AWS服务时,偶尔会出现以下错误:

When trying to connect to an AWS service via Boto3, I occasionally get the following error:

NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV3Handler'] Check your credentials

此命令在配置了IAM角色的EC2实例上运行.此错误很少发生.

This is running on an EC2 instance with an IAM Role configured. This error happens rarely.

推荐答案

IAM角色通过AWS元数据服务提供凭证.Boto3将连接到该服务以获取凭据,但是此连接可能会超时.默认情况下,Boto3不会重试与元数据服务的连接,但是可以通过将环境变量 AWS_METADATA_SERVICE_NUM_ATTEMPTS 设置为大于1的数字来更改此连接.

IAM roles provide credentials via the AWS metadata service. Boto3 will connect to this service to get credentials, but this connection can time out. By default, Boto3 will not retry connections to the metadata service, but this can be changed by setting the environment variable AWS_METADATA_SERVICE_NUM_ATTEMPTS to a number higher than 1.

请参见文档:

在尝试使用IAM角色配置的EC2实例上检索凭据时,boto3只会在放弃之前尝试进行一次从实例元数据服务中检索凭据的尝试.如果您知道您的代码将在EC2实例上运行,则可以增加此值以使boto3多次重试,然后再放弃.

When attempting to retrieve credentials on an EC2 instance that has been configured with an IAM role, boto3 will only make one attempt to retrieve credentials from the instance metadata service before giving up. If you know your code will be running on an EC2 instance, you can increase this value to make boto3 retry multiple times before giving up.

这篇关于Boto3间歇性NoAuthHandlerFound错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 03:30