我正在为lambda函数编写无cloudformation无服务器yaml。如果IsProduction为true,则我需要一个条件参数reservedConcurrency
为100,如果为false,则为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
答案 0 :(得分:1)
您不能在functions
文件内的serverless.yml
块中使用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}