Get stage from handler.js

How do I get stage value from handler.js?

If you are using Api Gateway then just
event.stage

Thanks man, but I am not using API gateway

I think I need to wait for serverless-helpers-js new version which is compatible with V1

Serverless will most likely have a solution for this post v1 final release, but in the meantime, check out: https://www.npmjs.com/package/serverless-plugin-write-env-vars which is both straightforward and reliable, just don’t forget to add require('dotenv').config() at the top of your handler.js!

We will have a much broader environment variable integration in the future, its a very important feature for us we just need a little more time until we can release it.

1 Like