Hey @nerdguru,
Serverless is definitely capable of this. Check out the docs on variables: https://serverless.com/framework/docs/providers/aws/guide/variables/
here’s an example of where I am setting my CORS origins per stage:
myLambdaFunction:
handler: functions/myLambdaFunction/handler.handler
events:
- http:
path: "v1/agents"
method: get
authorizer: authorization
integration: lambda
cors:
origins:
- ${self:custom.stages.${opt:stage, self:provider.stage}.vars.URL-Access-Control-Allow-Origin}
headers:
- Content-Type
- X-Amz-Date
- Authorization
- X-Api-Key
- X-Amz-Security-Token
allowCredentials: true
hope this helps… it’s very powerful.
If you want to reference code inside your actual lambda code, you can use the serverless-plugin-write-env-vars
plugin:
cheers,
Stretch