-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix CloudFormation SNS Subscribe with Region parameter #12676
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 - Preflight, Unit21 579 tests ±0 19 927 ✅ ±0 6m 14s ⏱️ -2s Results for commit 300ca0c. ± Comparison against base commit a298730b. |
Test Results (amd64) - Acceptance7 tests ±0 5 ✅ ±0 3m 8s ⏱️ +2s Results for commit 300ca0c. ± Comparison against base commit a298730b. |
Test Results - Alternative Providers597 tests 420 ✅ 14m 46s ⏱️ Results for commit 300ca0c. |
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 for this solution 👍 .
Interesting how cross-region support is integrated on some CFn resource definitions.
@@ -153,3 +156,23 @@ def update( | |||
@staticmethod | |||
def attr_val(val): | |||
return json.dumps(val) if isinstance(val, dict) else str(val) | |||
|
|||
@staticmethod | |||
def _get_client( |
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.
In the future we should make this utility available to other resource providers.
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.
Agreed! We should probably have a simpler way to re-use the client_params
, as I now have to access private attributes via request.aws_client_factory._client_creation_params
, which isn't great. Maybe we should save them somewhere, I'm not sure 🤔
LocalStack Community integration with Pro 2 files ±0 2 suites ±0 1h 42m 4s ⏱️ - 2m 49s Results for commit 300ca0c. ± Comparison against base commit a298730b. |
Test Results (amd64) - Integration, Bootstrap 5 files 5 suites 2h 22m 13s ⏱️ Results for commit 300ca0c. |
Motivation
As reported by #12670, we have an issue with cross-region subscriptions in CloudFormation for SNS.
This is because we need the client that does the subscription to be configured in the same region as the topic. This was for example an issue in CDK here: aws/aws-cdk#13707, solved by properly adding the
Region
parameter with aws/aws-cdk#17273We did not consider this parameter at all.
I'm solving this by properly creating a client in the right region manually before doing the
Subscribe
call.However, this is quite hacky because CloudFormation does not expose an easy way to do that with the exact same client configuration as the exposed default factory.
I'm directly accessing internal to make sure I'm creating the exact same client, but this is not great.
I prefer that to using
connect_to
however, because CloudFormation has a special client, and it takes into account all the proper credentials and not just theaccount_id
andregion
(access key, secret key and token).Changes
AWS::SNS::Subscription