Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to detect when a node module is running as a Google Cloud Function?

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?

like image 277
John Doherty Avatar asked Oct 28 '25 14:10

John Doherty


1 Answers

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.

Example

// Other variables FUNCTION_REGION, FUNCTION_IDENTITY, FUNCTION_TIMEOUT_SEC, etc;
const isGoogleCloudEnv = !!process.env.GCP_PROJECT 
// ...
like image 129
ajorquera Avatar answered Oct 31 '25 06:10

ajorquera



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!