examples icon indicating copy to clipboard operation
examples copied to clipboard

How to reference variable from environment variable and fallback to default value as a ref one?

Open Ali-Dalal opened this issue 5 years ago • 0 comments

Provider: AWS I have the following resource in serverless.yml

resources:
  Resources:
    MyQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName:${self:provider.stage}_my_queue

What I need to do is to reference an environment variable from .env file and fallback to ref MyQueue if .env file is missing that key.

referencing a resource is like this

MY_QUEUE:  { Ref: MyQueue }

how we can do it like this

MY_QUEUE: ${env:MY_QUEUE, {Ref: MyQueue} } # this not valid one

Ali-Dalal avatar Apr 30 '20 09:04 Ali-Dalal