3

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

1 Answers1

1

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'}
Aaron Stuyvenberg
  • 3,437
  • 1
  • 9
  • 21