Is there any way to check if a node function/module is running as a Google Cloud Function other than setting an environment variable via the console and checking for that?
There are a few environment variables that are set automatically. You could check if they are defined. If so, you are running in google cloud environment. More Info.
// Other variables FUNCTION_REGION, FUNCTION_IDENTITY, FUNCTION_TIMEOUT_SEC, etc;
const isGoogleCloudEnv = !!process.env.GCP_PROJECT
// ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With