Environment Variables inside cloud_build.yaml + PHP

1,513 views
Skip to first unread message

Bill

unread,
Jan 7, 2021, 6:43:23 PM1/7/21
to Google App Engine
Hi,
The environment variables set inside the cloud_build.yaml file, are they read by PHP? I mean, are they treated as system environment variables?

I am considering using environment variables inside the cloud_build.yaml file (via substitution) this way I can drop the use of app.yaml and not expose my environment variables inside a file on source control.

Thanks
Bil 

jstsetinin

unread,
Jan 8, 2021, 5:26:59 AM1/8/21
to Google App Engine
Hello,
I think it is possible but you have to use "options" field and "env" subfield. According to documentation [1] in "env" subfield you can specify "a list of global environment variable definitions that will exist for all build steps in this build. If a variable is defined in both globally and in a build step, the variable will use the build step value." 

Bilal Haidar

unread,
Jan 8, 2021, 9:14:52 AM1/8/21
to google-a...@googlegroups.com
The documentation says use options to define a list of global env variables to be used within all build steps.

Are these env variables going to persist when Laravel app (PHP) runs and reads the system environment variables? That's the tricky part.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/4643414b-7557-450b-b8ce-c6bd1f09b421n%40googlegroups.com.

Daniel (Google Cloud Support)

unread,
Jan 11, 2021, 9:37:14 AM1/11/21
to Google App Engine
The environment variables defined on the cloudbuild.yaml file will be available within the instances running your Cloud Build steps. For the variables to persist on your App Engine application and be used at runtime they'd need to be defined on the app.yaml file. So, as explained on this stackoverflow posts [1], [2] you'd need to compile the app.yaml at runtime within a Cloud Build step. Additionally, you could always use other alternatives to hide your secrets, such as Secret Manager [3] if your environment variables contain sensible information you don't feel comfortable to be exposed within a file in source control.

Reply all
Reply to author
Forward
0 new messages