无服务器中的条件资源



我想根据 env var 的存在有条件地添加一个 AWS 资源。我尝试了serverless-cloudformation-parameter-setter但是在部署时出现一般错误,并且看不到需要做什么来修复它

我正在尝试部署一个简单的lambda + SQS堆栈,如果定义了env var,则还将队列订阅到env var表示的主题 - 或者如果未定义var,则根本不做该部分,只需lambda和队列

这是我尝试过的:

plugins:
- serverless-cloudformation-parameter-setter
provider:
  name: aws
  runtime: nodejs8.10
  region: eu-west-1
functions:
  update:
    handler: index.update
    events:
    - sqs:
        arn:
          Fn::GetAtt:
          - Queue
          - Arn
custom:
  cf-parameters:
    SourceTopicArn: "${env:UPDATE_SNS_ARN}"
resources:
  Parameters:
    SourceTopicArn:
      Type: string
  Resources:
    Queue:
      Type: "AWS::SQS::Queue"
    Subscription:
      Type: "AWS::SNS::Subscription"
      Condition: SourceTopicArn
      Properties:
        TopicArn:
          Ref: SourceTopicArn
        Endpoint:
          Ref: Queue

我收到的错误是:The CloudFormation template is invalid: Template format error: Unrecognized parameter type: string

如果我删除所有参数内容,它可以正常工作

Type必须是String,而不是string。请参阅文档中支持的参数数据类型部分。

最新更新