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

Implementation of AWS::S3::* Resource Provider support for CloudFormation #9404

Merged
merged 7 commits into from Oct 24, 2023

Conversation

Morijarti
Copy link
Contributor

@Morijarti Morijarti commented Oct 19, 2023

Changes

Implementation of support for:

  • "AWS::S3::BucketPolicy"
  • "AWS::S3::Bucket"

@Morijarti Morijarti added aws:cloudformation AWS CloudFormation semver: patch Non-breaking changes which can be included in patch releases labels Oct 19, 2023
@coveralls
Copy link

coveralls commented Oct 19, 2023

Coverage Status

coverage: 82.788% (-0.2%) from 82.939% when pulling bd8b327 on feat/cfn_s3 into 375b379 on master.

@github-actions
Copy link

github-actions bot commented Oct 19, 2023

LocalStack Community integration with Pro

       2 files  ±0         2 suites  ±0   1h 16m 13s ⏱️ + 7m 23s
2 262 tests ±0  1 687 ✔️ ±0  575 💤 ±0  0 ±0 
2 263 runs  ±0  1 687 ✔️ ±0  576 💤 ±0  0 ±0 

Results for commit bd8b327. ± Comparison against base commit 375b379.

♻️ This comment has been updated with latest results.


try:
s3_client.delete_bucket_policy(Bucket=model["BucketName"])
except s3_client.exceptions.ClientError:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In original code of BaseLegacyProvider we were catching Exception. Instead of it, I went with more specific exception here.
Should I revert it to Exception?

Copy link
Member

Choose a reason for hiding this comment

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

@bentsku Probably would know if the NotFound exception is considered a ClientError.

Copy link
Contributor

@bentsku bentsku Oct 20, 2023

Choose a reason for hiding this comment

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

why do we need to manually delete the bucket policy in the first place? Shouldn't it be deleted by deleting the bucket?
It actually does not raise an error if the policy doesn't exist, just validated the behaviour in AWS 👍 it does not raise an error either in LocalStack with either v2 or v3 provider.

But it will raise a BucketNotFound if the bucket does not. Those are ClientError.
The only weird error in S3 is with HeadBucket, because it does not have a body, it will raise a ClientError but not a specific s3_client.exceptions.ClientError, I'm not sure why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed explicit deletion of bucket policies and replaced exception with more general ClientError
Let me know If there is anything else I can do to improve the code.

@Morijarti Morijarti marked this pull request as ready for review October 20, 2023 14:12
# Conflicts:
#	localstack/services/cloudformation/resource_provider.py
- Replaced exception caught during call to head bucket
Copy link
Member

@pinzon pinzon left a comment

Choose a reason for hiding this comment

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

LGTM

@Morijarti Morijarti merged commit 931e9f7 into master Oct 24, 2023
27 checks passed
@Morijarti Morijarti deleted the feat/cfn_s3 branch October 24, 2023 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:cloudformation AWS CloudFormation semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants