Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud Run: detecting that you are in the cloud (vs. on your laptop)

When testing code that talks to SQL, it's convenient to use different connection strings depending on whether you connect from the cloud (SQL instance) or your dev laptop (localhost). In GAE programs, you can do this:

if os.environ.get('GAE_ENV') == 'standard': # connect with local socket; else you're in your laptop, connect via TCP

Is there a similar variable visible to cloud run jobs?

Thank you!

1 1 354
1 REPLY 1

I found some hereCLOUD_RUN_JOB seems to work. Would appreciate confirmation from a Googler that this is future safe.