Looking to establish a connection between an SQS queue and an SNS topic located in a different account using CDK (TypeScript). Presented below is the code snippet (contained within a stack) that I believe should facilitate this integration. However, I have a few concerns highlighted beneath the code (I haven't deployed this yet as I'm still exploring the process).
const topic = Topic.fromTopicArn(
this,
`${stackName}-topic`,
`arn:aws:sns:${region}:${accountno}:SubscriptionChanges`
);
topic.addSubscription(
new SqsSubscription(queue, {
filterPolicy: {
type: SubscriptionFilter.stringFilter({
whitelist: [
'filter1',
],
})
},
})
);
}
- Is it permissible to use fromTopicArn to instantiate the topic construct when I am not the owner of the topic (since the topic exists in a different account requiring cross-account setup)?
- Can a SQS subscription be created without declaring the topic variable as shown in the first line above?
Reviewing the official documentation, I observed code examples demonstrating similar setups but limited to interactions within the same AWS account. Seeking insights from individuals with practical experience regarding this scenario.