Postinstall script not receiving env_variables

140 views
Skip to first unread message

Ryan Sacha

unread,
Aug 16, 2018, 11:23:33 AM8/16/18
to Google App Engine
I have an issue with a node js app engine project, where the main script/server.js receives the environment variables just fine. but the "postinstall" doesn't.

{
 
"name": "citation-generator",
 
"version": "4.1.0",
 
"main": "server.js",
 
"scripts": {
   
"start": "node server.js",
   
"postinstall": "gulp --production"
 
},
...
}


Gulp doesn't receive the custom env variables i set on app.yaml, in fact i tested it by logging process.env from gulp.js and it's just the generic variables on a linux environment.

my app.yaml:




runtime
: nodejs
env
: flex


manual_scaling
:
  instances
: 1
resources
:
  cpu
: 1
  memory_gb
: 0.5
  disk_size_gb
: 10


env_variables
:
  FOO
: "BAR"


handlers
:
- url: /.*
  script
: auto
  secure
: always
  redirect_http_response_code
: 301


Ryan Sacha

unread,
Aug 16, 2018, 11:50:33 AM8/16/18
to Google App Engine
Just to add - unrelated to the above issue - the handlers part also doesn't work, it's supposed to redirect to https but it doesn't.

I have checked config on the console and it looks like it does upload the config in app.yaml just fine:

08-16_16-31-23.png

Katayoon (Cloud Platform Support)

unread,
Aug 16, 2018, 8:04:19 PM8/16/18
to Google App Engine

Note that environment variables defined in app.yaml aren’t intended to be made available on the Container Builder during the App Engine flexible deployment process. One of the often used reasons for environment variables is for secrets. They are then being persisted for anyone who can access the image at a later date.


A workaround can be writing your own Build Requests for Container Builder, which allows you to specify environment variables, and then deploying the built images to App Engine.


You can also pass these variables to Cloud Builder in the `env` portion of the BuildStep that needs them.


For the issue on the secure handler, I recommend to post your full detailed question to Stack Overflow, using the supported Cloud tags since Google Groups are reserved for general Google Cloud Platform-end product discussions and not for technical questions.


Reply all
Reply to author
Forward
0 new messages