How get Environment Variables from lambda (nodejs aws-sdk)

Max Vinogradov picture Max Vinogradov · Jan 28, 2018 · Viewed 22.9k times · Source

We can set up Environment Variables in aws-lambda for example via AWS SAM:

Environment:
    Variables:
      TABLE_NAME: !Ref Table

How can I get this variables from current lambda via Node JS AWS-SDK?

Answer

Richie Mackay picture Richie Mackay · Jan 28, 2018

Just as you would any environment variable from node

const tableName = process.env.TABLE_NAME;