Skip to content

S3 bucket creation step fails for certain regions #4

@arjun289

Description

@arjun289

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 aws/aws-cli#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions