config is a library that provides centralized configuration management functionality for webapp2 and Cloud Endpoints apps. Acts as a client for config_service.
The library can work in two modes: remote and fs. In remote mode the library fetches configs from a configuration service. In fs mode it uses file system as a source of configs. The library defaults to fs mode if URL of the config service is uknown.
Remote mode allows updating configuration without re-deploying your application.
endpointslibrary in app.yaml.
libraries: - name: endpoints version: "1.0"
config.ConfigApiCloud Endpoints service.
<appid>in the config service's config root directory and put global configuration files there.
To link a LUCI app to a config service:
Make sure you are in the
administrators group of the app.
Open the exported Config Cloud Endpoints service in the app with API Explorer (replace
<host> with the app hostname):
In the request body:
service_hostnameis the config service hostname (e.g.
trusted_service_accountis the service account of the config service (e.g.
Tell the configure service that your app may fetch your configs by adding your app to
services.cfg of the config service.
get* functions in api.py, such as
store_last_good parameter. Pass
True to avoid doing a roundtrip to the config service. Instead they are fetched from the datastore and a cron job updates the config files in the background.
Add to your
app.yaml to enable the config component:
includes: - components/config libraries: - name: jinja2 version: "2.6" - name: webapp2 version: "2.5.2" - name: webob version: "1.2.3"
In this mode configuration files are read from the file system. It is convenient for local development or when using a config service is an overkill.
The config files are read from
<app root>/configs/<config_set>/CONFIGS/<config file path>, for example if your app is
foo.appspot.com and your global config file is called
settings.cfg, it will be read from
When running locally, the
app id is specified in your
When the app is uploaded to the real AppEngine, the configs from your local checkout are uploaded too. To update them, reupload your app.
Configuration service supports config validation at the import time. For each file in a revision, the config service contacts the apps that claim they can validate the file and if any of the apps returns an error, the whole revision is rejected.
config.validation module to specify which config files your app can validate and how to validate them. See the module docstring for more info.