我的云形成模板无法在不产生任何错误的情况下创建资源

My cloud formation template fails to create resource without producing any error

我有一个包含数百个资源的大型 CloudFormation 模板。所有都成功更新,在更新期间,除了一个:SNS 警报主题。

部署堆栈时,我没有收到任何错误,但即使主题不存在,也永远不会创建主题。

我不期望任何人能够为我提供解决方案,但我只是想知道如何解决问题。从部署中获取输出会很有帮助,但事件太少而且实际上没有反映资源的数量updated/created,因此它们很少帮助找出问题所在。

模板验证也成功,但这几乎是必然的,因为部署也成功了。

关于一般的实时 CloudFormation 堆栈故障排除,CloudFormation 最近刚刚添加了对 Change Sets 的支持,这应该有助于您在尝试将更新应用于 运行 之前预览更改并解决潜在的更新问题堆叠。

具体关于 SNS 主题,使用 AWS::SNS::Topic resource works correctly. However, if you are using a TopicName property in your SNS resource, make sure that the name is unique across your entire AWS Account, as noted in the documentation:

从头开始​​创建 SNS 主题

Resource names must be unique across all of your active stacks. If you reuse templates to create multiple stacks, you must change or remove custom names from your template.

因此,在多次部署的堆栈中重复使用常量 TopicName 可能会导致您描述的问题。

此外,如果您尝试使用 added/removed 订阅更新现有 CloudFormation 创建的主题,请注意 documentation 中的以下 重要 通知:

Important

After you create an Amazon SNS topic, you cannot update its properties by using AWS CloudFormation. You can modify an Amazon SNS topic by using the AWS Management Console.

作为通过 CloudFormation adding/removing 订阅现有 SNS 主题的潜在解决方法,cloudformation-helpers library containing a Custom::SnsSubscription resource (example) 可能会有所帮助。