Manage Secrets and Config in the Cloud
Inject credentials safely at runtime.
Manage Secrets and Config in the Cloud is a free MLOps Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MLOps Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Keep Secrets Out of Images
A database password baked into an image leaks to anyone who pulls it. Inject secrets at runtime instead, never at build time. 🔐
Config vs Secrets
Plain settings like a model path are config. Sensitive values like API keys are secrets. Both stay outside the image, handled differently.
Env Vars for Plain Config
Non-sensitive settings ride in as environment variables at deploy time. The same image then behaves differently in staging and production.
gcloud run deploy model-api --set-env-vars MODEL_STAGE=ProductionRead Them in Code
Your app reads those values with os.environ. Provide a sensible default so the code still runs locally without every variable set.
stage = os.environ.get("MODEL_STAGE", "Staging")Use a Secret Manager
Real secrets belong in a secret manager like AWS Secrets Manager or Google Secret Manager. It encrypts, versions, and audits access.
Reference, Do Not Embed
You attach a secret by reference, and the platform mounts the value at runtime. The secret never appears in your deploy command.
gcloud run deploy model-api --set-secrets API_KEY=api-key:latestMount as Env or File
A secret can land as an environment variable or a mounted file. Certificates and long keys are often cleaner read from a file path.
Grant Least Privilege
Give the service account only the secrets it truly needs. This least privilege rule shrinks the blast radius if a token ever leaks.
Rotate Without Redeploying
Pin secrets to a version like latest, then rotate by adding a new version. New instances pick it up with no image rebuild needed.
Never Log a Secret
Logs are stored and widely readable, so a printed key is as good as public. Scrub secrets from output and from error traces alike.
One Image, Many Environments
With config and secrets external, a single image runs everywhere. You change behavior by swapping variables, not by rebuilding.
Quick Check
Let us check the safe way to handle an API key.
Recap
You split config from secrets, injected both at runtime, used a secret manager, and rotated safely. One image now runs anywhere. 🔑
Frequently asked questions
Is the “Manage Secrets and Config in the Cloud” lesson free?
Yes — the full text of “Manage Secrets and Config in the Cloud” is free to read here on the web, and the MLOps Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MLOps Academy course, upgrade to CoddyKit PRO.
What will I learn in “Manage Secrets and Config in the Cloud”?
Inject credentials safely at runtime. You practise MLOps Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MLOps Academy?
No prior experience is required. MLOps Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Manage Secrets and Config in the Cloud” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MLOps Academy lesson?
Yes. Every MLOps Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Push Your Image to a Registry
- Deploy to a Serverless Container Runtime
- Configure Autoscaling and Concurrency
- Manage Secrets and Config in the Cloud