Skip to content
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

Refactor util to create S3 buckets with location constraints #5898

Merged
merged 2 commits into from
Apr 20, 2022

Conversation

whummer
Copy link
Member

@whummer whummer commented Apr 20, 2022

Minor refactoring in utils to create S3 buckets with location constraints. Buckets now need to be created with the correct region / location constraint (for parity with AWS).

We can use the create_s3_bucket(..) util function to simplify this task and streamline creation of buckets across the codebase. Intended to be used in places where we need to create temporary buckets for other services, e.g., in the case of CloudFormation, to avoid these exceptions:

localstack_main |     s3_client.create_bucket(Bucket=CUSTOM_RESOURCES_RESULTS_BUCKET)                                                                                                                                                                          
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 415, in _api_call                                                                                                                                  
localstack_main |     return self._make_api_call(operation_name, kwargs)                                                                                                                                                                                      
localstack_main |   File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 745, in _make_api_call                                                                                                                              
localstack_main |     raise error_class(parsed_response, operation_name)
localstack_main | botocore.exceptions.ClientError: An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent t

@whummer whummer temporarily deployed to localstack-ext-tests April 20, 2022 17:23 Inactive
@whummer whummer requested a review from thrau as a code owner April 20, 2022 17:54
@whummer whummer temporarily deployed to localstack-ext-tests April 20, 2022 17:54 Inactive
@whummer whummer temporarily deployed to localstack-ext-tests April 20, 2022 17:56 Inactive
@whummer whummer temporarily deployed to localstack-ext-tests April 20, 2022 17:59 Inactive
Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 91.884% when pulling fe9ebb7 on util-create-bucket into b5d1dd3 on master.

@whummer whummer merged commit b4a94cf into master Apr 20, 2022
@whummer whummer deleted the util-create-bucket branch April 20, 2022 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants