Cloudformation SNS 模板验证错误
Cloudformation SNS template validation error
我正在尝试创建 sns 订阅,但出现模板验证错误。
'MySNSTopic' 是名为 testnstopic 的 cloudformation 堆栈的逻辑 ID。
这是正确的吗?谁能解释一下我应该给'Ref'这里
什么价值
"TopicArn" : {
"Ref": "MySNSTopic"
}
模板验证错误:
Template format error: Unresolved resource dependencies [MySNSTopic] in the Resources block of the template
代码:
{
"Resources": {
"MySubscription" : {
"Type" : "AWS::SNS::Subscription",
"Properties" : {
"Endpoint" : "test@abc.com",
"Protocol" : "email",
"TopicArn" : {
"Ref": "MySNSTopic"
}
}
}
}
}
要跨不同堆栈使用属性,您需要明确导出一端的值并导入到另一堆栈。
在你的情况下,你可能需要这样的东西:
堆栈:sns-test
{
"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"
}
}
}
}
}
我正在尝试创建 sns 订阅,但出现模板验证错误。
'MySNSTopic' 是名为 testnstopic 的 cloudformation 堆栈的逻辑 ID。
这是正确的吗?谁能解释一下我应该给'Ref'这里
什么价值"TopicArn" : {
"Ref": "MySNSTopic"
}
模板验证错误:
Template format error: Unresolved resource dependencies [MySNSTopic] in the Resources block of the template
代码:
{
"Resources": {
"MySubscription" : {
"Type" : "AWS::SNS::Subscription",
"Properties" : {
"Endpoint" : "test@abc.com",
"Protocol" : "email",
"TopicArn" : {
"Ref": "MySNSTopic"
}
}
}
}
}
要跨不同堆栈使用属性,您需要明确导出一端的值并导入到另一堆栈。
在你的情况下,你可能需要这样的东西:
堆栈:sns-test
{
"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"
}
}
}
}
}