1回答
- 新しい順
- 投票が多い順
- コメントが多い順
0
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."
回答済み 2年前
関連するコンテンツ
- AWS公式更新しました 10ヶ月前
- AWS公式更新しました 7ヶ月前
The Subscribe API call does return the subscription ARN though. From https://docs.aws.amazon.com/sns/latest/api/API_Subscribe.html:
Response Elements
The following element is returned by the service.
SubscriptionArn
The ARN of the subscription if it is confirmed, or the string "pending confirmation" if the subscription requires confirmation. However, if the API request parameter ReturnSubscriptionArn is true, then the value is always the subscription ARN, even if the subscription requires confirmation.
Type: String