-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix delete method of AWS::SNS::TopicPolicy CFn resource #12831
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
Conversation
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 1h 51m 6s ⏱️ Results for commit 34ce328. |
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 21m 17s ⏱️ - 21m 29s Results for commit 34ce328. ± Comparison against base commit e558996. This pull request removes 1261 and adds 1 tests. Note that renamed tests count towards both.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks a lot for addressing this, and also fix the default Action
in Moto, this is great!
@markers.aws.validated | ||
@markers.snapshot.skip_snapshot_verify( | ||
paths=[ | ||
"$..Statement..Action", # TODO: see https://github.com/getmoto/moto/pull/9041 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot for fixing this 😄 this is gonna remove a few snapshot skips!
except ClientError as err: | ||
if "NotFound" not in err.response["Error"]["Code"]: | ||
raise | ||
|
||
return ProgressEvent( | ||
status=OperationStatus.IN_PROGRESS, | ||
status=OperationStatus.SUCCESS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: I suppose this is the main fix, right? the Delete operation would never finish as it never returned SUCCESS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this + the default policy, because sending an empty attribute value to moto raises and error here: https://github.com/getmoto/moto/blob/338cb256a4ab938f24b5b29ec079ed26a9d0c093/moto/sns/models.py#L137-L139
@@ -25,6 +26,38 @@ | |||
SnsMessageProtocols = Literal[SnsProtocols, SnsApplicationPlatforms] | |||
|
|||
|
|||
def create_default_sns_topic_policy(topic_arn: str) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice addition! I'm always torn with this kind of utils in models.py
, but it makes sense. It's going to nicely be used when we start creating topics in LocalStack directly 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to put it elsewhere. what would be a good place? should we create a utils module, or should it just go into the provider? i could also move it to the resource provider directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is good for now! If we internalize, we’ll create a util folder and move things around! Sorry for the delay 😄
As a side note, it will hopefully be possible in the future to skip list item like the troublesome Right now, it's not possible to skip individual list item |
Motivation
This was a short detour on my main quest to get a CloudTrail scenario test working. The test uses a CDK construct to configure CloudTrail to send delivery events to SNS, which also creates a topic policy for SNS. I noticed the stacks weren’t deleting properly because the TopicPolicy resource was stuck in a retry loop.
I also raised getmoto/moto#9041 to get rid of the
SNS:Receive
action in the default policy that moto creates incorrectly.Changes