S3 using boto and SigV4 - missing host parameter

☆樱花仙子☆ 提交于 2019-12-30 04:37:30

问题


when developing i used a S3 bucket in ireland, which worked well. For production i want to use the new "Frankfurt" location of S3, but apparently the new Frankfurt region uses the "SigV4" which breaks my python script.

When adding the following block to ~/.boto, i get the following error:

~/.boto:

[s3]
use-sigv4 = True

Error:

File "/usr/lib/python2.6/site-packages/boto/__init__.py", line 141, in connect_s3
return S3Connection(aws_access_key_id, aws_secret_access_key, **kwargs)
File "/usr/lib/python2.6/site-packages/boto/s3/connection.py", line 196, in __init__
"When using SigV4, you must specify a 'host' parameter."
boto.s3.connection.HostRequiredError: BotoClientError: When using SigV4, 
you must specify a 'host' parameter.

Can anybody please tell me how to specify the "host" parameter? I couldn't find this parameter in a aws/boto documentation.


回答1:


Here's the docs for your exact error, as well as the exact source code that's creating the S3Connection (and in turn, your error).

In creating the S3Connection(aws_access_key_id, aws_secret_access_key, **kwargs), you need to pass in an additional item host=..., which should be a simple string like 's3.amazonaws.com', or similar for your setup.

Solution:

You can add this to your kwargs being passed:

kwargs.update({'host': 's3.amazonaws.com'})

or call it manually like:

S3Connection(aws_access_key_id, aws_secret_access_key, host='s3.amazonaws.com', **kwargs)


来源:https://stackoverflow.com/questions/26744712/s3-using-boto-and-sigv4-missing-host-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!