AWS "sam deploy" 函数超时。堆栈保持 "REVIEW_IN_PROGRESS" 状态

AWS "sam deploy" function times out. Stack stays in "REVIEW_IN_PROGRESS" status

我正在尝试部署一个非常简单的函数,如下面的 template.yaml 文件所示。它创建一个“samcli-deploy1629444458”变更集并保持“CREATE_IN_PROGRESS”状态。当我检查它的详细信息时,它没有任何变化。堆栈的事件、资源、输出部分也没有任何内容。 “sam deploy”命令失败并附有输出,堆栈保持“REVIEW_IN_PROGRESS”状态,我需要手动删除它。

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  AWS Test backend.


Globals:
  Function:
    Timeout: 3
    Runtime: nodejs12.x

Resources:
  HelloWorldApi:
    Type: AWS::Serverless:Api
    Properties:
      Name:API
      StageName: Prod

  HelloWorldFunction:
    Type: AWS::Serverless::Function 
    Properties:
      CodeUri: hello-world/
      Handler: app.lambdaHandler
      Events:
        HelloWorld:
          Type: Api 
          Properties:
            RestApiId: !Ref HelloWorldApi
            Path: /hello
            Method: get

“sam deploy”命令的输出。

Waiting for changeset to be created..
Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/lib/deploy/deployer.py", line 292, in wait_for_changeset
    waiter.wait(ChangeSetName=changeset_id, StackName=stack_name, WaiterConfig=waiter_config)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/botocore/waiter.py", line 53, in wait
    Waiter.wait(self, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/botocore/waiter.py", line 362, in wait
    raise WaiterError(
botocore.exceptions.WaiterError: Waiter ChangeSetCreateComplete failed: Max attempts exceeded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/sam", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/lib/cli_validation/image_repository_validation.py", line 76, in wrapped
    return func(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 153, in wrapped
    raise exception  # pylint: disable=raising-bad-type
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 122, in wrapped
    return_value = func(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/lib/utils/version_checker.py", line 42, in wrapped
    actual_result = func(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/cli/main.py", line 90, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/commands/deploy/command.py", line 206, in cli
    do_cli(
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/commands/deploy/command.py", line 345, in do_cli
    deploy_context.run()
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/commands/deploy/deploy_context.py", line 155, in run
    return self.deploy(
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/commands/deploy/deploy_context.py", line 229, in deploy
    result, changeset_type = self.deployer.create_and_wait_for_changeset(
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/lib/deploy/deployer.py", line 458, in create_and_wait_for_changeset
    self.wait_for_changeset(result["Id"], stack_name)
  File "/usr/local/Cellar/aws-sam-cli/1.28.0/libexec/lib/python3.8/site-packages/samcli/lib/deploy/deployer.py", line 297, in wait_for_changeset
    reason = resp["StatusReason"]
KeyError: 'StatusReason'

更新: 如果我在“sam deploy”命令失败后等待足够长的时间并且没有手动删除堆栈,它最终会失败并出现以下错误:

 1 validation error detected: Value '[AWS::Serverless:Api, AWS::IAM::Role, AWS::Lambda::Function, AWS::Lambda::Permission]' at 'typeNameList' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 204, Member must have length greater than or equal to 10, Member must satisfy regular expression pattern: [A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}::[A-Za-z0-9]{2,64}(::MODULE){0,1}]

我在 .yaml 文件中找不到任何可能导致此错误的长名称。

这是一个简单的错字,您少了一个冒号:

Type: AWS::Serverless:Api

应该是

Type: AWS::Serverless::Api