我有一个cdk堆栈,可同时创建lambda和snS主题。设置策略以允许Lambda发布到snS主题。
我很难在我的lambda运行时代码中指定Topic ARN,因为从技术上讲它还没有创建,只是在堆栈中。
如何在Lambda代码中引用主题ARN,以便Lambda发布到该主题? Lambda用python编写。我正在使用fromAsset
方法(https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-readme.html)在堆栈中指定我的lambda运行时代码。
sns = boto3.client('sns')
responce = sns.publish(
TopicArn="arn would go here --- not sure what to put here w/ no arn",Message="my_message"
)