不能 return 来自云形成 yaml 中的条件函数的整数

Can't return integer from Conditional function in cloud formation yaml

我正在为 lambda 函数编写 cloudformation 无服务器 yaml。如果 IsProduction 为真,我需要一个条件参数 reservedConcurrency 为 100,如果为假,则为 20。但是当我部署 yaml 文件时发生错误: You should use integer as reservedConcurrency value on function

resources:
  Conditions:
    IsProduction:
      Fn::Equals:
        - ${self:provider.stage}
        - production

functions:  
  somefunction:
    handler: functions/somefunction
    timeout: 300
    events:
      - sqs:
          arn:
            Fn::GetAtt: [ somequeue, Arn ]
          batchSize: 10
    reservedConcurrency:
      Fn::If:
        - IsProduction
        - 100
        - 20

您不能在 serverless.yml 文件内的 functions 块中使用 Cloudformation 内部函数。

改为尝试使用 nested variables

custom:
  concurrency:
    prod: 100

functions:  
  somefunction:
    handler: functions/somefunction
    timeout: 300
    events:
      - sqs:
          arn:
            Fn::GetAtt: [ somequeue, Arn ]
          batchSize: 10
    reservedConcurrency: ${self:custom.concurrency.${self:provider.stage}, 20}