【问题标题】:AWS sam deploy with nested stacks - errors from child stacks don't bubble upAWS sam 使用嵌套堆栈部署 - 来自子堆栈的错误不会冒泡
【发布时间】:2021-05-04 08:06:09
【问题描述】:

我刚刚开始我的 serverless/cloudformation/AWS SAM 之旅。我创建了一个具有 AWS::CloudFormation::Stack 类型资源的堆栈,并将我的一些资源分离到该子堆栈中。

当我执行sam build 然后sam deploy 时,我收到以下错误:

Embedded stack arn:aws:cloudformation:us-
west-2:111111111111:stack/ParentStack-
ChildStack-1QK94LXRA71CS/f9885e30-631c-11eb-
bfd8-021cb123b7ed was not successfully created: The
following resource(s) failed to create: [DynamoDBTable]. 
-
The following resource(s) failed to create:
[ChildStack].

当然,我真正想知道的是嵌套堆栈中的哪个资源创建失败,以及为什么。当我将子堆栈中的资源复制/粘贴到父 .yaml 文件并重建/重新部署时,我看到:

 One or more parameter values were invalid: Some index key
 attributes are not defined in AttributeDefinitions. Keys:
 [userID], AttributeDefinitions: [userId] (Service:
 AmazonDynamoDBv2; Status Code: 400; Error Code:
 ValidationException; Request ID:
 SMJDHUT0CQKM8IBQJVMAIJM4RRVV4KQNSO5AEMVJF66Q9ASUAAJG;    
 Proxy: null)

这是我在构建父堆栈时希望在输出中看到的:导致子堆栈失败的错误。

这导致我使用了一个相当曲折的工作流程:在主堆栈中构建资源,然后在它们正确构建时将它们分离到一个独立的堆栈中。一定有更好的方法,我相信社区知道一些我不知道的事情。

在 CloudFormation 列车上,你们如何调试子堆栈?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    这是正常行为,您必须从 AWS Console 获得帮助,或者在这种情况下使用 AWSW CLI

    Deploy error reporting is not showing the reason of failure when using nested stacks. #5974

    Feature Requests for nested stacks

    Why doesn't the error tell me what's wrong?:

    CloudFormation 将资源的创建和更新传递给负责这些资源的服务。当资源无法创建/更新时,资源的后备服务会向堆栈返回一个原因,该原因会在事件中记录为状态原因。 Child StackCloudFormation::Stack 资源,因此它是由 CloudFormation 创建的。据 CloudFormation 所知,它在尝试实际执行任何操作时并没有遇到错误。它所做的与 CloudFormation 相关的一切都很好。责任在于未能创建它的服务资源。因此,Child Stack 告诉Parent-Stack 它只是因为服务未能创建而失败,而不是因为 CloudFormation 服务方面的问题。

    您可以在此处阅读更多信息CloudFormation troubleshooting

    【讨论】:

      猜你喜欢
      • 2020-04-14
      • 2018-06-21
      • 2019-04-20
      • 2021-09-11
      • 2013-08-25
      • 1970-01-01
      • 2020-10-31
      • 2018-10-27
      • 2018-10-01
      相关资源
      最近更新 更多