There is no direct way via CDK to get the subscription ARN. Neither CfnTopic nor CfnSubscription return the subscription ARN or provide a way to retrieve it.
A helpful way to determine whether a value is available in CDK is this:
- Does the API provide it? Looking at the sns subscribe api call, it doesn't return the arn.
- Does CloudFormation's AWS::SNS::Subscription provide it? Looking at the doc, there are no attributes on this resource type.
This is a good indicator that CDK doesn't support it either, which we see in the CfnTopic and CfnSubscription docs.
You could use the list-subscriptions api in your CDK code to find the arn and store it in a CfnOutput.
An alternate approach you could take is to use a lambda-backed custom resource to create the subscription, use the list-subscriptions API to find the arn for the new subscription, and return the arn. But this seems like the "long way around the barn."
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated 8 months ago
- How do I create a subscription between my Amazon SQS queue and an Amazon SNS topic in CloudFormation?AWS OFFICIALUpdated a year ago
- How do I recreate a "Deleted" Amazon SNS topic subscription for an Amazon SQS queue in another AWS account?AWS OFFICIALUpdated 2 months ago
- How can I get my Amazon SQS subscription to successfully receive a notification from my Amazon SNS topic?AWS OFFICIALUpdated 5 months ago
- EXPERTpublished 4 months ago
- EXPERTpublished 5 months ago