Python / Boto 3 - Adding an S3 Bucket in a none eu-west-1 region

**AWS error "An error occurred (InvalidRequest) when calling the CreateBucket operation: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256."**

To fix this error, you need to use “signature_version=’s3v4’”.  This code works fine :)

#!/usr/bin/env python
import boto3.session
from botocore.client import Config
import logging

session = boto3.session.Session()

s3_client = session.client('s3',

bucket_name = 'milesd-002'

aws_region = 'eu-central-1'

    response = s3_client.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={'LocationConstraint': aws_region})
except Exception as e:
    logging.warn("Unable to setup version on *%s* - %s", bucket_name, e)

Author | Miles Davenport

Career programmer, who designs, assembles, fixes, and supports customers, software and systems.