-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
bug: SNS cross region topic subscription fails (CloudFormation) #12670
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
Comments
Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Support if you are a licensed user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines. |
Hello @codenem and thanks for your report! Just to confirm, is it possible to subscribe to a topic in Region A with a client configured in region B? I've just given it a try in AWS, and it raises an exception for me: $ aws sqs create-queue --queue-name my-queue --region eu-west-1
{
"QueueUrl": "https://eu-west-1.queue.amazonaws.com/<account-id>/my-queue"
}
$ aws sns create-topic --name my-topic --region us-east-1
{
"TopicArn": "arn:aws:sns:us-east-1:<account-id>:my-topic"
}
$ aws sns subscribe --topic-arn "arn:aws:sns:us-east-1:<account-id>:my-topic" --protocol sqs --notification-endpoint "arn:aws:sqs:eu-west-1:<account-id>:my-queue" --region eu-west-1
An error occurred (InvalidParameter) when calling the Subscribe operation: Invalid parameter: TopicArn The error message is different and I will fix that. From the documentation, I believe the
https://docs.aws.amazon.com/sns/latest/dg/sns-cross-region-delivery.html Please correct me if you have this exact setup working in AWS, but currently I'm unable to make it work. Thanks! |
Thanks for your answer @bentsku , indeed. I have provided those commands for quick reproduction, but we get the error from our CDK deployment on LocalStack (works on AWS). I'll double check the code and get back to you here, but we definitely get a different behavior (we use the same CloudFormation code). |
@codenem, oh, in this case, this might a parameter we're not explicitly using in our CloudFormation handling. If you could share a small snippet from the template maybe, that could help debug the issue. Thanks again! |
This might be somewhat related to aws/aws-cdk#13707, and we might not consider the CloudFormation |
Yeah maybe, we're creating the subscription like so in Go: queue := awssqs.NewQueue(
defaultStack,
namer.Format("queue"),
&awssqs.QueueProps{
QueueName: namer.Format("queue"),
},
)
topic := awssns.NewTopic(
stack,
namer.Format("topic"),
&awssns.TopicProps{
EnforceSSL: aws.Bool(true),
MasterKey: masterKey,
TopicName: namer.Format("topic"),
},
)
topic.AddSubscription(
awssnssubscriptions.NewSqsSubscription(
queue,
&awssnssubscriptions.SqsSubscriptionProps{},
),
) I'm trying another approach, as for why it works in AWS, I guess they set the region now, or maybe when it is with an SQS queue (and not a lambda) that subscribes they have a different code branch. |
Actually looking at the fix from the issue you linked, the subscription can either be in the topic's region or in the subscriber's (queue / lambda). So it seems that LS's implementation does not reflect this yet? As for why the CLI command must subscribe in the same region, it is a separate topic than CDK. |
@codenem yes, exactly. We did not support the Looking at the fix for CDK you shared, it seems they have different code branch in CDK to automatically set the If you could check that the |
@bentsku I can confirm that for the subscriptions to a topic residing in another region than the subscriber, then the template shows the |
Awesome @codenem, then the PR linked will fix the issue for you once merged and available. Thanks for confirming! 🙏 I'll update you and ping you here once the fix is available in the |
Hello again @codenem, the fix is now part of the Thank you! |
Hi @bentsku, I can confirm that using the |
Awesome, thanks for confirming @codenem, and the help getting through the end of it! I'll close the issue, thanks again for the report 🙏 |
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
Current Behavior
Starting version
4.1.0
, subscribing to a topic from a different region fails with the following:I think the bug has been introduced by #12175, with the intention of raising the error for legit cases.
The code might be pretty self explanatory of the bug. If I understand correctly, here we should check the store corresponding to the region of the topic ARN we want to subscribe to, not the store of the region we are subscribing from.
Expected Behavior
Subscribing to a topic from a different region succeeds.
How are you starting LocalStack?
With a docker-compose file
Steps To Reproduce
How are you starting localstack (e.g.,
bin/localstack
command, arguments, ordocker-compose.yml
)Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: