Waiter ChangeSetCreateComplete failed:Waiter 遇到终端故障状态

Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state

我正在学习 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:

得到了这个输出

error : Waiting for changeset to be created.. Error: Failed to create changeset for the stack: hello-world-sam, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Invalid template property or properties [Table]

您的 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

在我的例子中,cfn linter 可以使用 yaml,错误(使用来自 cmd 的 aws CLI)只是

Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state:

For expression "Status" we matched expected path: "FAILED"

您应该检查 AWS console → CloudFormation → {stack_name} → 更改集

我的错误原因在这里

Status reason

No updates are to be performed.

可能会帮助某人