Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Interpolation inside of .env* files? #62

Closed
bastiankoetsier opened this issue Jul 20, 2020 · 2 comments
Closed

Question: Interpolation inside of .env* files? #62

bastiankoetsier opened this issue Jul 20, 2020 · 2 comments
Labels

Comments

@bastiankoetsier
Copy link

Hey,

first of all: Thank you for your work on this plugin. We just started implementing a serverless api and need env-var support. Unfortunately, we need access to Cloudformation-Outputs inside of the env vars, e.g. for a Subnet-ID.
What we did so far is more of a workaround by specifying the env vars multiple times:

custom:
  stage: "${opt:stage,'dev'}",
  env:
    dev:
      dbHost: "127.0.01"
    prod: 
      dbHost: "${cf:Stack.dbHost}"

...
functions:
  test:
  ..
    environment: 
      dbHost: "self:custom.env.${opt.stage}.dbHost

(no guarantees on correct indentation 😄 )
We would love to manage all of the env variables in their dedicated files and just have a ${env:dbHost} in the functions section without the ugly repetition in custom . Is there a way to achieve this?

Thanks in advance!

@herebebogans
Copy link

herebebogans commented Jul 27, 2020

This isn't really related to this plugin but theres a number of ways you can do what you want using serverless variables.

assuming your stack name has the stage / environment as the suffix the simplest would be
${cf:stackprefix-${self:custom.stage}.dbHost}

@neverendingqs
Copy link
Owner

Closing this off for now due to age. Feel free to reopen if you have additional comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants