Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I want to detect if my code is getting executed in AWS Lambda environment. Is there a good, documented way to do it?

Currently, I'm depending on the existence of environmental variable LAMBDA_TASK_ROOT which was described in the Exploring The AWS Lambda Runtime Environment blog post which feels wrong

1 Answer

0 votes
by (44.4k points)

After the lambda entry point, you can set a Global variable or an Environment variable so that you can track manually. In node.js it is like this:

exports.handler = function(event, context, callback) {

    process.env['LAMBDA_ENV'] = 'true';

    ...

};

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
asked Jul 25, 2019 in AWS by yuvraj (19.1k points)

Browse Categories

...