serverless / typescript

TypeScript definitions for Serverless Framework service configuration
141 stars 25 forks source link

useDotenv doesn't work #55

Closed ianzone closed 2 years ago

ianzone commented 2 years ago

Hi, my setting is like

useDotenv: true,

provider: { name: 'aws', region: 'us-west-1', runtime: 'nodejs14.x', logRetentionInDays: 7, lambdaHashingVersion: '20201221', environment: { ClientID: '${env.ClientID}', ClientSecret: '${env.ClientSecret}', }, },

When I call console.log(process.env.ClientID, process.env.ClientSecret) in lambda, it literally printed '${env.ClientID} ${env.ClientSecret}'.

Did I use useDotenv wrong? How can I pass values in .env to lambda function when deploying?

ianzone commented 2 years ago

Hi, my setting is like

useDotenv: true,

provider: { name: 'aws', region: 'us-west-1', runtime: 'nodejs14.x', logRetentionInDays: 7, lambdaHashingVersion: '20201221', environment: { ClientID: '${env.ClientID}', ClientSecret: '${env.ClientSecret}', }, },

When I call console.log(process.env.ClientID, process.env.ClientSecret) in lambda, it literally printed '${env.ClientID} ${env.ClientSecret}'.

Did I use useDotenv wrong? How can I pass values in .env to lambda function when deploying?

oops, just found my typo, it should be environment: { ClientID: "${env:ClientID}", ClientSecret: "${env:ClientSecret}", },