-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S3ResponseError: 400 Bad Request #3
Comments
@djandruczyk TL;DR I couldn't reproduce this (Fedora 24) This issue is related to newer regions like us-east-2, eu-central-1 etc. that force the AWS4-HMAC-SHA256 signature, but there's already a workaround in the code for that: https://github.com/dliappis/amiimporter/blob/master/amiimporter.py#L95 (see also the boto issue). For reference, I tried creating a bucket in us-east-2 (Ohio) as you have and the process worked fine for me. Your boto version is a bit old; I don't recommend relying on boto python libraries shipped with the OS.
OR
Make sure that you don't mix both approaches shown above. If in doubt just Here are the versions of my AWS related pip libs:
It would be nice to switch to boto3 in Should also mention that if you can afford to create your bucket in a different older region like |
New regions like us-east-2 provide challenges (e.g. requiring AWS4-HMAC-SHA256 signatures for S3) that despite hacks prove to be increasingly difficult with boto2. Switching to boto3 resolves those issues and will allow us to remove the dependency for spawning aws-cli for the actual import-image command. Relates #3
@djandruczyk I was able to reproduce your problem. It seems boto2 has fallen behind with the new signature methods required by S3 in newer regions. I took the plunge and switched much of the code to use boto3; you can try the version I pushed in this branch https://github.com/dliappis/amiimporter/tree/switch-to-boto3 and see if it helps. Keep in mind that as it is now, it will copy the produced artifact in 4 regions, which you can adjust here: https://github.com/dliappis/amiimporter/blob/switch-to-boto3/amiimporter.py#L200 |
Using the pip method it still fails... ./amiimporter.py --vboxfile /tmp/CentOS7-20161123_0.box --s3bucket s3://amis-ohio --region=us-east-2 --verbose I tried both to a bucket in virginia (US east-1) and ohio (us-east-2) boto 2.43.0 python --version Ubuntu 16.04.1 LTS 64 bit |
@djandruczyk Can you try the boto3 version: https://github.com/dliappis/amiimporter/tree/switch-to-boto3 ? |
Any updates on this? |
Haven't touched this for several years. Did you try the boto3 branch: https://github.com/dliappis/amiimporter/tree/switch-to-boto3 I mentioned earlier? (4yrs old ... not sure if it works!) |
amiimporter.py --vboxfile /tmp/CentOS7-20161123_0.box --s3bucket my-amis --region=us-east-2 --verbose
INFO:root:Uploading ./tmpdir/box-disk1.vmdk to s3
Traceback (most recent call last):
File "/usr/local/bin/amiimporter.py", line 214, in
main(make_opt_parser().parse_args(sys.argv[1:]))
File "/usr/local/bin/amiimporter.py", line 208, in main
upload_vmdk_to_s3(opts, vmdkfile)
File "/usr/local/bin/amiimporter.py", line 96, in upload_vmdk_to_s3
bucket_location = bucket.get_location()
File "/usr/lib/python2.7/dist-packages/boto/s3/bucket.py", line 1144, in get_location
response.status, response.reason, body)
boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request
InvalidRequest
The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.0B2D268921129D32uIt4GoSguVmj+Lh9VPtuhwb73affiu/2OOoqW7+l06m3cZIWYABs7zjTd+n0KJa5CvuaNco0Fk4=I have verified my environment variabels are properly exported for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY_ID, and it still gives me the same results..
Ubuntu 16.04 64 bit using python2.7 and python-boto-2.38.0
The text was updated successfully, but these errors were encountered: