Open neeraj87 opened 2 years ago
You could pass it as an environmental var.
Another way, is to have a per environment setting in the custom section of your serverless.yml:
custom:
stages:
prod:
logDays: 60
dev:
logDays: 14
You can then reference it in your function. Or in the custom area if you want it applied globally.
functions:
myAPI:
handler: build/lambda.handler
logRetentionInDays: ${self:custom.stages.${self:custom.stage}.logDays}
See the doco for more details: https://www.serverless.com/framework/docs/providers/aws/guide/variables#recursively-reference-properties
I want to modify the log retention period based on which env my lambda is deployed for. The below is my serverless.yml code.
As you can see the lambda is deployed to different environment which is specified by ${self:custom.stage} - the stage var is coming from a buildspec file and can have two values dev or prod.
If the stage is dev then I want the retention period to be 14 days and if its prod then 60 days. Is there a way to achieve this?