11

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.

fabs
  • 77
  • 1
  • 1
  • 13
  • 1
    if you only want to use sigv4 for eu-central (very ugly): `os.environ['S3_USE_SIGV4'] = 'True'` then after you are done `del os.environ['S3_USE_SIGV4']` so that you don't have to provide a `host` for older code. – Nasser Al-Wohaibi Nov 27 '14 at 13:45

1 Answers1

13

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)
VooDooNOFX
  • 4,674
  • 2
  • 23
  • 22
  • Thank you, i managed to get the script working with your example. Do you also know if there is a possibility to provide the host parameter in the boto config file? – fabs Nov 07 '14 at 13:54
  • You'd have to give the value from the boto.cfg file yourself. The function seems to pull a default value from the config, but only after it's already flagged to produce an error. So, you'll *have* to provide it in the instantiation of the `S3Connection`. Now, that can come from the config, but it's up to you to do that. – VooDooNOFX Nov 07 '14 at 23:43