question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQS subscription to cross-region SNS topic not working via addSubscription

See original GitHub issue

When I try to subscribe an SQS queue in one account to an SNS topic in another account and another region using topic.addSubscription(), I get error “Invalid parameter: TopicArn.” This works when adding a subscription to a the same account/region or a different account but same region. But it fails when subscribing to a different account and region:

topicInRegionA.addSubscription(new SqsSubscription(queueInRegionB));

I thought this was supposed to be fixed by #3842?

Reproduction Steps

  1. Try to subscribe an SQS queue to a topic in another region using addSubscription()

Error Log

1/13 | 5:11:07 PM | CREATE_FAILED        | AWS::SNS::Subscription          | MyQueue/MyServicealphauswest2MyTopic915AE08F (MyQueueMyServicealphauswest2MyTopic915AE08F58613436) Invalid parameter: TopicArn (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: ...)
        new Subscription (...CDK/node_modules/@aws-cdk/aws-sns/lib/subscription.js:29:9)
        \_ Topic.addSubscription (...CDK/node_modules/@aws-cdk/aws-sns/lib/topic-base.js:23:9)
        \_ AppStack.bindCustomComponents (...CDK/dist/lib/custom/app-stack.js:48:43)
        \_ Object.<anonymous> (...CDK/dist/lib/app.js:66:18)
        ...

Environment

  • CLI Version : 1.30.0 (build 4f54ff7)
  • OS : Red Hat variant
  • Language : TypeScript

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jacoblangstoncommented, Mar 17, 2021

This is still an issue.

Steps to reproduce:

  • Create an SNS topic in an account in us-east-1
  • In a CDK project, configured for a different account and region (us-west-2), create a queue, and subscribe to the SNS Topic.

This is the CDK code I’m using:

  const queue = new sqs.CfnQueue(this, 'MyQueue', {
      queueName: 'MyQueue',
      kmsMasterKeyId: cmk.keyId,
      visibilityTimeout: 900,
    });
    
  const topicSubscription = new sns.CfnSubscription(this, 'MySubscription', {
    topicArn: 'arn-for-sns-topic',
    region: scopedAws.region,
    endpoint: queue.attrArn,
    protocol: 'sqs',
  });
0reactions
github-actions[bot]commented, Nov 11, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending Amazon SNS messages to an Amazon SQS queue ...
Amazon SNS supports the cross-region delivery of notifications to Amazon SQS queues and to AWS Lambda functions. When one of the Regions is...
Read more >
Cross Account AWS SNS to SQS Subscription Tutorial
It's common to want to subscribe an SQS queue to an SNS topic in another AWS account. Unfortunately, the steps to follow are...
Read more >
AWS Cross Account SNS to SQS Subscription - Setup Guide
In this method, the SNS Topic owner subscribes the SQS Queue consumer. This is possible either through the AWS CLI, CDK, CloudFormation, or...
Read more >
Four AWS CLI Commands to Set Up a Cross-Region/Account ...
First, create the Amazon SNS topic: · Next, give permission to subscribe to the topic: · Third, add the Lambda permission to allow...
Read more >
aws.sns.TopicSubscription - Pulumi
TopicSubscription uses a provider with a different region than the SNS topic, this provider will fail to create the subscription. NOTE: Setup of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found