Declare a credential dependency
Save this asservice.py:
Secret("SERVICE_API_KEY") only names the secret, and only workloads that list
it receive the value, as an environment variable. The name lives in code, the
value never does.
Provision the value from Python
Save this asconfigure_secrets.py beside service.py:
set() creates or replaces the value. In CI, the same script can call
api_key.set(os.environ["SERVICE_API_KEY"]) with the value from the CI secret
store. With SERVICE_URL set to your API’s URL, the function runs:
set() returns contains the value.
Rotate or remove a secret
Rotation is the setup script with a new value, then a redeploy so new containers get it.create(value) refuses to overwrite, update(), get(),
and delete() do the rest, and a secret stays stored until deleted.
Image.with_secrets([...]) covers build-time credentials.
