Added explicit check for a bucket when deploying a stack#6171
Added explicit check for a bucket when deploying a stack#6171
Conversation
whummer
left a comment
There was a problem hiding this comment.
LGTM, great set of changes @giograno ! 👍
We could try to cover this with a small test. For example, we already have a small test template with S3 NotificationConfiguration here:
localstack/tests/integration/test_cloudformation.py
Lines 262 to 281 in 0a4359f
So we could parameterize this test with a flag whether to create the bucket before deploying the stack:
localstack/tests/integration/test_cloudformation.py
Lines 1004 to 1006 in 0a4359f
dominikschubert
left a comment
There was a problem hiding this comment.
LGTM 🪣 🚀 , minor exception handling nit
| bucket_name = props.get("BucketName") | ||
| try: | ||
| s3_client.head_bucket(Bucket=bucket_name) | ||
| except Exception: |
There was a problem hiding this comment.
nit: too broad. we should probably explicitly check for it being a not found exception here and avoid swallowing any unrelated issues here
There was a problem hiding this comment.
Added a stronger check 👍
|
@whummer I parametrized the test as you suggested. However, since the issue does not appear for the default region |
f64916e to
07e43a4
Compare
thrau
left a comment
There was a problem hiding this comment.
LGTM! thanks for jumping on this. i don't know much about CFN but implementation looks good :-)
|
Simplified the test a bit, as discussed with @whummer. Actually, we don't even need to have a specific region backend with the CloudFormation client to replicate the bug, given the global name space for S3 buckets. |
Introduced a fixture to get clients for a specific region
9be5379 to
bf002bd
Compare
Issue coming from support.
The problem came from the fact that we consider a resource as not created if it does not have notification configs attached.
This causes a
BucketAlreadyOwnedByYouerror outsideus-east-1.I changed the deploy template with a function that explicitly checks if the bucket exists and, if not, proceeds to create it.
Feedback are welcome, quite a newbie here on CloudFormation.