Amazon ec2 “波托间歇式”;无法加载凭据";使用EC2 IAM角色

Amazon ec2 “波托间歇式”;无法加载凭据";使用EC2 IAM角色,amazon-ec2,boto3,amazon-iam,amazon-elastic-beanstalk,botocore,Amazon Ec2,Boto3,Amazon Iam,Amazon Elastic Beanstalk,Botocore,我使用弹性Beanstalk环境来部署web应用程序,并为应用程序将在其上运行的实例设置了IAM角色 在99.99%的时间里,一切都是完美无瑕的,但我会在日志中间歇性地看到错误,请求失败会显示如下botocore错误: File "/opt/python/run/venv/local/lib/python3.6/site-packages/boto3/resources/factory.py", line 339, in property_loader self.load() File "/

我使用弹性Beanstalk环境来部署web应用程序,并为应用程序将在其上运行的实例设置了IAM角色

在99.99%的时间里,一切都是完美无瑕的,但我会在日志中间歇性地看到错误,请求失败会显示如下botocore错误:

File "/opt/python/run/venv/local/lib/python3.6/site-packages/boto3/resources/factory.py", line 339, in property_loader
  self.load()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/boto3/resources/factory.py", line 505, in do_action
  response = action(self, *args, **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
  response = getattr(parent.meta.client, operation_name)(**params)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
  return self._make_api_call(operation_name, kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/client.py", line 648, in _make_api_call
  operation_model, request_dict, request_context)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/client.py", line 667, in _make_request
  return self._endpoint.make_request(operation_model, request_dict)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/endpoint.py", line 102, in make_request
  return self._send_request(request_dict, operation_model)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/endpoint.py", line 132, in _send_request
  request = self.create_request(request_dict, operation_model)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/endpoint.py", line 116, in create_request
  operation_name=operation_model.name)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/hooks.py", line 356, in emit
  return self._emitter.emit(aliased_event_name, **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/hooks.py", line 228, in emit
  return self._emit(event_name, kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/hooks.py", line 211, in _emit
  response = handler(**kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/signers.py", line 90, in handler
  return self.sign(operation_name, request)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/signers.py", line 157, in sign
  auth.add_auth(request)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/botocore/auth.py", line 357, in add_auth
  raise NoCredentialsError
tocore.exceptions.NoCredentialsError: Unable to locate credentials
我不知道这是否只是一种竞争条件,在这种情况下,IAM凭据正在轮换(或类似的情况),而实例的boto客户端正在尝试使用它们

关于补救或优雅地处理此故障的任何提示

附言


我们有同样的问题。我在botocore repo中发行了一期债券

我们现在使用的解决方法是通过重试错误装饰器进行重试。到目前为止,它是有效的

boto3==1.9.75
botocore==1.12.239
python==3.6.8