CloudFormation模板无效:模板格式错误:资源名称AuthorizerApiGatewayAuthorizerproject-dev为非字母数字

时间:2018-11-12 21:38:46

标签: amazon-web-services serverless

我有以下serverless.yml文件:

service:                      test-project

provider:
  name:                       aws
  stage:                      ${opt:stage, 'project-dev'}
  runtime:                    nodejs8.10
  endpointType:               REGIONAL

params:
  user_pool_arn:              ${opt:user_pool_arn}

functions:
  login:
    name:                     login
    handler:                  src/login.handler
    events:
    - http:
        integration:          lambda
        path:                 login
        method:               post
        cors:                 true
        request:
          passThrough:        WHEN_NO_TEMPLATES
          template:
            application/json: '{ "username": $input.json("$.username"), "password": $input.json("$.password") }'

  logout:
    name:                     logout
    handler:                  src/logout.handler
    events:
    - http:
        integration:          lambda
        path:                 logout
        method:               post
        cors:                 true
        authorizer:
          name:               authorizer
          arn:                ${self:params.user_pool_arn}
        request:
          passThrough:        WHEN_NO_TEMPLATES
          template:
            application/json: '{ "username": "$context.authorizer.claims.sub" }'

plugins:
- serverless-aws-alias
- serverless-prune-plugin

然后我尝试像这样部署它:

sls deploy --region us-east-1 --stage project-dev --alias "project-dev" --user_pool_arn XXXXX

但是我遇到这个错误:

The CloudFormation template is invalid: Template format error: Resource name AuthorizerApiGatewayAuthorizerproject-dev is non alphanumeric.

我认为此错误是由于我的 stage alias project-dev引起的。但是我需要他们像那样。而且我知道这是无服务器而非AWS的错误,因为我没有强制使用名称AuthorizerApiGatewayAuthorizerproject-dev,我什至不在乎该名称。

我正在使用以下配置:

 OS:                     linux
 Node Version:           8.10.0
 Serverless Version:     1.32.0

有趣的是,我发现了以下错误报告:

Error when creating aliases with "-" in the name #68

Resource name is non alphanumeric. #2017

Template format error: Resource name *** is non alphanumeric #2474

他们都确认了问题,并说已解决!

0 个答案:

没有答案