Secrets & Config¶
tiktok-api loads all runtime configuration from AWS at import time via
fs_config (config/cfg.py). Environment is selected by ENVIRONMENT
(prd default, stg allowed). Nothing config-related is hardcoded in
source.
Where values live¶
| Value | Store | Path | Exported as |
|---|---|---|---|
| MySQL connection | Secrets Manager | /<env>/mysql/tiktok |
MYSQL_SETTINGS |
| Admin API keys | Secrets Manager | /<env>/tiktok-api/admin-api-keys |
ADMIN_API_KEY_GET, ADMIN_API_KEY_POST |
| S3 bucket + region | SSM Parameter Store | /<env>/tiktok-api/s3 |
S3_SETTINGS |
Rule of thumb: anything that authenticates (DB password, API keys) is a secret and lives in Secrets Manager. Non-secret config (bucket name, region) lives in SSM Parameter Store, which is cheaper and not a secret store. S3 object access itself uses the instance/task IAM role, not stored keys.
SSM parameter format¶
/<env>/tiktok-api/s3 is a String parameter holding JSON:
{"bucket_name": "assets-<env>.dadsnews.com", "region": "us-east-1"}
Current values:
- /stg/tiktok-api/s3 -> {"bucket_name":"assets-stg.dadsnews.com","region":"us-east-1"}
- /prd/tiktok-api/s3 -> {"bucket_name":"assets-prd.dadsnews.com","region":"us-east-1"}
Deploy prerequisite¶
The SSM parameters above must exist before the service boots, or
config/cfg.py raises on import. The instance role
SkynetEC2InstanceRole (shared stg + prd) must allow ssm:GetParameter
on the /<env>/tiktok-api/* tree (granted via the inline policy
SkynetAppConfigSSMRead, covering common/stg/prd). String params
need no KMS permission.
To (re)create the parameters:
aws ssm put-parameter --region us-east-1 --name "/stg/tiktok-api/s3" --type String \
--value '{"bucket_name":"assets-stg.dadsnews.com","region":"us-east-1"}' --overwrite
aws ssm put-parameter --region us-east-1 --name "/prd/tiktok-api/s3" --type String \
--value '{"bucket_name":"assets-prd.dadsnews.com","region":"us-east-1"}' --overwrite