-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Sns/v2 topic migration #13205
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
Sns/v2 topic migration #13205
Conversation
Test Results - Alternative Providers132 tests 9 ✅ 23s ⏱️ Results for commit f713a3c. ♻️ This comment has been updated with latest results. |
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 59m 50s ⏱️ - 59m 22s Results for commit f713a3c. ± Comparison against base commit e60ff8e. This pull request removes 1975 and adds 7 tests. Note that renamed tests count towards both.This pull request removes 225 skipped tests and adds 2 skipped tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 1h 28m 28s ⏱️ Results for commit f713a3c. ♻️ This comment has been updated with latest results. |
bentsku
left a comment
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 work, this is looking great! I believe this to be a sound base to continue building on 🚀
The only issue is using plain Python class for the store attributes, once this is resolved, I believe we're good to go.
The rest is minor nits and simplification of the code.
Nice new coverage with new snapshot tests, this is really great to see! 👌
| # TODO: | ||
| raise InvalidParameterException("Fix this Exception message and type") |
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.
note for later: this is about idempotency when creating, right? This was pretty tricky for subscriptions, might be worth looking into subscribe to see if we can take some things from there 👍
| topics = {"Topics": [{"TopicArn": t.arn} for t in store.topics.values()]} | ||
| topics = PaginatedList(topics["Topics"]) | ||
| page, nxt = topics.get_page( | ||
| lambda topic: topic["TopicArn"], next_token=next_token, page_size=100 |
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.
nit: using the topic ARN as the pagination token might be a bit of an issue (some client might not handle the arn format for that), but this can left as is for now, just a thought
|
Currently, only patch changes are allowed on main. Your PR labels (semver: minor, docs: skip) indicate that it cannot be merged into the main at this time. |
bentsku
left a comment
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, this is great!
Thanks for addressing the comments, I believe there are only a few left and then we're good to merge 👍
It would be good to move the CreateTopic logic in the operation so that it's clearer where it is applied, and remove some redundant attributes of the topic.
The rest are questions, nits and thoughts about cross-region topic access that we will need to consider.
Once the CreateTopic logic has been cleaned up, we're good to merge 👍
| """ | ||
| :param arn: the Topic ARN | ||
| :param context: the RequestContext of the request | ||
| :return: the Moto model Topic |
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.
nit: comment: not the Moto model anymore
2nd comment: we will want to add the multi region flag sooner than later I believe, because right now we changed the behavior to raise an exception if the region of the request is different from the ARN, but this not should not be the default behavior for many operations. Just need to be kept in mind for the follow-up PRs
bentsku
left a comment
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 for addressing the comments! this is good to go, my comments are mostly about keeping tracks of some things to fix in follow-ups 👍 this looks great, thanks a lot 🙏
| { | ||
| "ContentBasedDeduplication": "false", | ||
| "FifoTopic": "false", | ||
| "SignatureVersion": "2", |
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.
nit: I think this is an oversight from the test, looking at all our tests, they all set the SignatureVersion to 2 when creating a fifo topic.
But looking at AWS, it doesn't seem like it sets this attribute by default:
$ aws us-east-1 sns create-topic --name test-topic.fifo --attributes FifoTopic=true
{
"TopicArn": "arn:aws:sns:us-east-1:<account-id>:test-topic.fifo"
}
$ aws sns get-topic-attributes --topic-arn arn:aws:sns:us-east-1:<account-id>:test-topic.fifo
{
"Attributes": {
"Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\"],\"Resource\":\"arn:aws:sns:us-east-1:<account-id>:test-topic.fifo\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"<account-id>\"}}}]}",
"Owner": "<account-id>",
"SubscriptionsPending": "0",
"TopicArn": "arn:aws:sns:us-east-1:<account-id>:test-topic.fifo",
"EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false,\"defaultRequestPolicy\":{\"headerContentType\":\"text/plain; charset=UTF-8\"}}}",
"SubscriptionsConfirmed": "0",
"FifoTopic": "true",
"DisplayName": "",
"ContentBasedDeduplication": "false",
"SubscriptionsDeleted": "0"
}
}But this is a nit, not blocking, something to consider to remove in a follow-up PR 👍 let's get this one merged! Sorry I missed it earlier
| # Invalid chars | ||
| for c in [":", ";", "!", "@", "|", "^", "%", " "]: | ||
| with pytest.raises(ClientError) as e: | ||
| sns_create_topic(Name=f"bad{c}name") | ||
| snapshot.match(f"name-invalid-char-{c}", e.value.response) |
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: it looks like the snapshot issue we discussed this morning is not part of the PR, will it be part of a follow-up? Not worries, not blocking either, I was wondering 😄
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.
works against v2 🤷
| @markers.snapshot.skip_snapshot_verify( | ||
| paths=[ | ||
| "$..Attributes.EffectiveDeliveryPolicy", | ||
| ] | ||
| ) |
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.
something I missed earlier too: it would be great to implement this default EffectiveDeliveryPolicy in a follow-up PR if we could keep track of it, as it is used in Publish to determine which content type to use for HTTP subscriptions. Not to be implemented in this PR either, this is just to keep track of it and remove in a follow-up for v2 👍
Motivation
First step of internalization of the SNS provider by migrating topics. This PR addresses both topics and topic attributes since they are intertwined
Changes
closes PNX-83, closes PNX-79