gpt4 book ai didi

aws-cloudformation - Cloudformation SNS 模板验证错误

转载 作者:行者123 更新时间:2023-12-03 07:37:19 26 4
gpt4 key购买 nike

我正在尝试创建 sns 订阅,但收到模板验证错误。

“MySNSTopic”是名为testsnstopic 的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" : "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6c18091f182c0d0e0f420f0301" rel="noreferrer noopener nofollow">[email protected]</a>",
"Protocol" : "email",
"TopicArn" : {
"Ref": "MySNSTopic"
}
}
}
}
}

最佳答案

要跨不同堆栈使用属性,您需要显式导出一端的值并导入到另一堆栈中。

在您的情况下,您可能需要这样的东西:

堆栈: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": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d7778736e5d7c6d747078746e69786f337e7270" rel="noreferrer noopener nofollow">[email protected]</a>",
"Protocol": "email",
"TopicArn": {
"Fn::ImportValue" : "sns-test-MySNSTopicExport"
}
}
}
}
}

关于aws-cloudformation - Cloudformation SNS 模板验证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47917472/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com