Configuration & secrets
Loading model
At runtime configuration is a single settings object built by Dynaconf from two generated
files:
from dynaconf import Dynaconf
settings = Dynaconf(environments=True, settings_files=['config/.secrets.json', 'config/settings.json'])
| File | Produced by | Contents |
|---|---|---|
|
|
Non-secret, per-environment configuration. |
|
|
Secrets fetched from AWS Secrets Manager. |
Neither file is committed. ENV_FOR_DYNACONF selects which environment block Dynaconf reads and
must equal ENV_NAME. Import the object anywhere as from config.config import settings.
|
Application code reads configuration only through |
settings_setup.py
Reads ENV_NAME (required, else ValueError) and writes config/settings.json with a default
block plus one environment block. release is production; every other name is a dev
environment with environment-suffixed resources and vendor sandboxes.
The default block holds environment-independent values: ENV_NAME, PROJECT_NAME,
ENTRUST_API_URL, ENTRUST_WORKFLOW_ID, the Thomson Reuters permissible-purpose codes and
certificate paths, the SWF coordinates, and SENTRY_DSN.
For non-release environments a numeric GCI is derived from the environment name
(__generate_gci — the first six digits of its SHA-1 hex digest) and used as
B2B_TASK_MANAGER_GCI; production uses 1.
The full list of keys, with production and dev values, is in Settings & secrets reference.
config_setup.py
Runs during the build (and locally via make secrets); needs AWS credentials. It selects
production versus dev from its first argument — production when invoked as
python config_setup.py codepipeline/automatic-uw-tool (CodeBuild passes
$CODEBUILD_INITIATOR), otherwise dev.
| Secrets Manager entry | Becomes |
|---|---|
|
The whole of |
|
|
|
|
|
|
Thomson Reuters secrets are referenced by name, not ARN: a bare name resolves within the caller’s account and region and stays stable across rotation, whereas the ARN’s 6-character suffix changes. The two environments live in different AWS accounts, which the ambient credentials already select.
Secrets consumed at runtime
| Secret | Used by |
|---|---|
|
|
|
CLEAR client (plus the PEM cert/key on disk) |
|
|
|
|
|
The |
|
|
|
Supplier event logger — with the non-secret |
Environments
| Env | ENV_NAME |
AWS account | Notes |
|---|---|---|---|
Dev |
any dev slug |
|
Vendor sandboxes, environment-suffixed resources, |
Prod |
|
|
Live vendors, |
Selected differences:
| Setting | release |
dev (<env>) |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
an API Gateway stage URL |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SHA-1-derived digits |
ENTRUST_API_URL and ENTRUST_WORKFLOW_ID are currently the same in both environments (they
live in the default block), so a dev environment exercises the real Onfido workflow with
whatever ENTRUST_TOKEN its account’s secret provides.
Gotchas
-
ENV_FOR_DYNACONFmust matchENV_NAME. If they diverge, Dynaconf silently falls back todefault-only values — you will see missing-attribute errors for anything environment-specific. -
Generated files are not editable configuration. Change
settings_setup.pyor the Secrets Manager entry and regenerate; do not hand-editsettings.jsonfor a deploy. -
releaseis production. Any otherENV_NAMEis treated as dev. -
The TR certificate must exist before the client is constructed —
ThomsonReutersClientresolves the cert/key paths ininit, and any handler that builds aTaskFactoryconstructs one, so a missing PEM breaks endpoints that never touch Thomson Reuters. -
A missing secret surfaces late.
settings.SOME_KEYraises only when first read, which for webhook secrets means at delivery time —ENTRUST_WEBHOOK_TOKENis read defensively withgetattr(settings, …, None)and logged as a configuration error rather than crashing.