Jimi
Jimi

Reputation: 1865

Is it possible to exclude some environment variables from serverless deploy?

I'm using Serverless for deploying my functions to AWS Lambda and Serverless Dot-Env to load in environment variables. However it seems there is no way to exclude some of these variables from the deployed Lambda. If you go on the Lambda dashboard on AWS you will find all variables listed on Environment variables, but what if I don't want some of them (like the NODE_ENV variable) to be there? I tried doing this in my serverless.yml file

exclude:
 - ${env:NODE_ENV}

But the variable was still there as you can see in the image below

So is there a way to hide such variables?

Upvotes: 1

Views: 1944

Answers (1)

Noel Llevares
Noel Llevares

Reputation: 16087

serverless-dot-env currently does not have a blacklist option but they do have a whitelist option.

Example from https://github.com/colynb/serverless-dotenv-plugin#plugin-options:

custom:
  dotenv:
    path: path/to/my/.env (default ./.env)
    basePath: path/to/ (default ./)
    include:
      - AUTH0_CLIENT_ID
      - AUTH0_CLIENT_SECRET

If you use include, only the variables you specified will be included.

Update: serverless-dotenv-plugin has an exclude option since Feb 2, 2020

Example from https://github.com/colynb/serverless-dotenv-plugin#plugin-options:

custom:
  dotenv:
    exclude:
      - NODE_ENV # E.g for Google Cloud Functions, you cannot pass this env variable.

Upvotes: 1

Related Questions