Skip to content

Configuration File

In order to load the metadata required by the library, a configuration file has to be created. By convention, this file should be named tenant_config.json and should be present at the same directory level as settings.BASE_DIR.

The configuration specified in this file is synced to the config store when the load_tenant_config command is run. Check the documentation for this command to know more about specifying alternate file names/file paths.

Schema

mapping_metadata

Required
This key is used for defining a one-to-one mapping of deployment keys to their corresponding translation values.

tenant_config

Optional

This key contains tenant specific configuration like DB, cache etc., The schema definition for this key is as follows:

{
    "tenant_config": {
        "tenant_identifier": {
            "service_identifier": {
                "orm_config": {
                    "orm_identifier": {
                        "template_alias": {... #db_config}
                    }
                },
                "cache_config": {
                    "template_alias": {
                        ... #cache_config
                    }            
                }  
            }
        }
    }
}

Note

The service_identifier key mentioned above should match the value provided for the TENANT_ROUTER_SERVICE_NAME setting as this is used for construction/de-construction of keys stored in the KV store.

Lets take a look at a more concrete example:

{
    "tenant-1.test.com": {
        "test_service": {
            "orm_config": {
                "django_orm": {
                    "default": {
                        "HOST": "...",
                        "NAME": "...",
                        "USER": "...",
                        "PASS": "...",
                        "PORT": "..."
                    }
                },
                "pymodm_orm": {
                    "default": {
                        "CONN_URL": "..."
                    }
                }
            },
            "cache_config": {
                "default": {
                    "LOCATION": "...",
                }
            }
        },
    },
    "tenant-2.test.com": {...}
}   

Important

The value provided for this key is synced to the config store only when settings.DEBUG is True i.e in the development environment. To know more about how the config store is populated in a production environment, click here