#How to access ${env} in Lambda Function?

4 messages · Page 1 of 1 (latest)

foggy prism
#

I've got a custom Amplify Lambda function, and I want to get the value of ${env} in it; for example values of 'dev', 'test', 'prod' for my team environments. How do I do this in "the Amplify way"?

I've done a bunch of googling, and there are answers from 2019 that involve hacking the CloudFormation templates, but I'm not sure if that applies anymore in 2024...

fierce wigeon
foggy prism
#

@fierce wigeon I’m using gen1. 😎

foggy prism
#

To answer my own question: There is an environment variable passed to every Amplify Lambda function called ENV. So all you have to do in your code is access process.env.ENV.