Set environment variables in GAE control panel

2019-07-19 00:54发布

I deploy my project to GAE over Github. There is some foreign API-key which I don't want to save in repository and make them public. Is it possible to set an environment variable for a project in GAE control panel so I can catch it in my application?

3条回答
小情绪 Triste *
2楼-- · 2019-07-19 01:10

You can store your keys in datastore. Later when you need them in the code, you can fetch them from datastore and cache them by memcache.

查看更多
相关推荐>>
3楼-- · 2019-07-19 01:18

You can define environment variables in configuration file for App Engine application. In case of Python, it is app.yaml

env_variables:
   MY_ENV_VAR: 'some_value'

You can find more details here.

There is no such a thing like project parameters that can be defined in Developers Console at the moment.

查看更多
做自己的国王
4楼-- · 2019-07-19 01:25

I prefer using the Datastore for keys like this. See the code in my answer at Securely storing environment variables in GAE with app.yaml

That code auto-generates placeholder values that you can then update from the developer console. Also, it uses the ndb library, so reading the keys is fast.

查看更多
登录 后发表回答