要跨不同堆栈使用属性,需要显式导出一端的值并导入到另一个堆栈中。
在你的情况下,你可能需要这样的东西:
堆栈:sns测试
{
"Resources": {
"MySNSTopic": {
"Type": "AWS::SNS::Topic"
}
},
"Outputs": {
"MySNSTopicOutput": {
"Description": "SNS topic arn",
"Value": {
"Ref": "MySNSTopic"
},
"Export": {
"Name": {
"Fn::Sub": "${AWS::StackName}-MySNSTopicExport"
}
}
}
}
}
堆栈:sns订阅
{
"Resources": {
"MySubscription": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": "jens@apimeister.com",
"Protocol": "email",
"TopicArn": {
"Fn::ImportValue" : "sns-test-MySNSTopicExport"
}
}
}
}
}