emr-demo icon indicating copy to clipboard operation
emr-demo copied to clipboard

S3 bucket creation step fails for certain regions

Open arjun289 opened this issue 1 year ago • 0 comments

In the script create_cfn_stack.py the create_bucket function fails for certain regions with the following error:

A client error (IllegalLocationConstraintException) occurred when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

Upon searching a bit I landed on this issue https://github.com/aws/aws-cli/issues/2603

For now I have mitigated the issue by modifying the code for my region and adding the LocationConstraint

def create_bucket(bucket_name):
    """Create an S3 bucket in a specified region

    :param bucket_name: Bucket to create
    :return: True if bucket created, else False
    """

    try:
        s3_client.create_bucket(
            Bucket=bucket_name,
            CreateBucketConfiguration={'LocationConstraint': 'ap-southeast-1'}
        )
        logging.info(f'New bucket name: {bucket_name}')
    except ClientError as e:
        logging.info('An error occurred !!', bucket_name)
        logging.error(e)
        return False
    return True

However I think the script can be modified to accommodate for this so it doesn't fail.

arjun289 avatar Jun 08 '23 13:06 arjun289