【问题标题】:Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure stateWaiter ChangeSetCreateComplete failed: Waiter 遇到终端故障状态
【发布时间】:2021-06-30 17:28:46
【问题描述】:

我正在学习 CloudFormation 教程,这是我的 AWS CloudFormation 模板:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: A starter AWS Lambda function.
Resources:
  helloworldpython3:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: app.lambda_handler
      Runtime: python3.6
      CodeUri: src/
      Description: A starter AWS Lambda function.
      MemorySize: 128
      Timeout: 3
      Environment:
        Variables:
          TABLE_NAME: !Ref Table
          REGION_NAME: !Ref AWS::Region
      Events:
        HelloWorldSAMAPI:
          Type: Api
          Properties:
            Path: /hello
            Method: GET
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref Table

Table:
  Type: AWS::Serverless::SimpleTable
  Properties:
    PrimaryKey:
      Name: greeting
      Type: String
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1

我可以使用aws cloudformation package 生成最终模板。但是当我尝试使用 sam deploy 部署它时,我从 shell 中得到了这个输出:

错误:等待创建变更集.. 错误:无法为堆栈创建变更集:hello-world-sam, 例如:Waiter ChangeSetCreateComplete 失败:Waiter 遇到了 终端故障状态:对于我们匹配的表达式“状态” 预期路径:“失败”状态:失败。原因:无效 模板属性或属性 [Table]

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation serverless aws-sam


    【解决方案1】:

    您的 YAML 格式不正确:

    AWSTemplateFormatVersion: "2010-09-09"
    Transform: "AWS::Serverless-2016-10-31"
    Description: A starter AWS Lambda function.
    Resources:
      helloworldpython3:
        Type: "AWS::Serverless::Function"
        Properties:
          Handler: app.lambda_handler
          Runtime: python3.6
          CodeUri: src/
          Description: A starter AWS Lambda function.
          MemorySize: 128
          Timeout: 3
          Environment:
            Variables:
              TABLE_NAME: !Ref Table
              REGION_NAME: !Ref AWS::Region
          Events:
            HelloWorldSAMAPI:
              Type: Api
              Properties:
                Path: /hello
                Method: GET
          Policies:
            - DynamoDBCrudPolicy:
                TableName: !Ref Table
      Table:
        Type: AWS::Serverless::SimpleTable
        Properties:
          PrimaryKey:
            Name: greeting
            Type: String
          ProvisionedThroughput:
            ReadCapacityUnits: 1
            WriteCapacityUnits: 1
    
    

    Table 应该在Resources 之下。使用像 cfn-python-lint 这样的 linter

    【讨论】:

      猜你喜欢
      • 2020-05-06
      • 2019-02-13
      • 1970-01-01
      • 2021-10-03
      • 1970-01-01
      • 2012-01-28
      • 2014-06-27
      • 2011-05-20
      • 2011-10-06
      相关资源
      最近更新 更多