I want to reference an external aws resource in serverless framework. However, if it does not exist, I want to fall back to a default value
For example:
functions:
create:
handler: posts.create
events:
- http:
path: posts/create
method: post
authorizer: arn: xxx:xxx:Lambda-Name
For authorizer, I want to reference a function if it exists, and if it does not exist, to default to another value
If your authorizer function is part of another cloud formation stack, you can use CloudFormation outputs to do this. If not, there are still several other variable solutions in the docs.
To do that conditionally, you'd combine it with a default. For example:
${cf:my-stack-${self:custom.stage}.AuthorizerArn, 'some-default-arn'}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With