Martin demonstrates how to update an existing Google Cloud Run service to securely access environment variables from Secret Manager without code changes.
Code shown in this episode → goo.gle/3boFqFb
Secret Manager docs → goo.gle/3eFNtzm
Secret Manager is a secure and convenient storage system for API keys, passwords, certificates, and other sensitive data that provides a central place and single source of truth to manage, access, and audit secrets across Google Cloud. In this episode of Serverless Expeditions Extended, Martin demos how you can update an existing Cloud Run service to use Secret Manager without changing any code and while applying the Principle of Least Privilege. Watch to learn how you can use Secret Manager with your Cloud Run service!
Timestamps:
- Intro
- Secret Manager
- Updating a Cloud Run service to use Secret Manager
- Putting the database password in Secret Manager
- Referencing Secret Manager from Cloud Run
- What did we achieve?
- Two other ways of accessing Secret Manager
- Wrap-up
Clarification on the video: if you mount a secret as an environment variable (and point it to the “latest” version of that secret), the latest value of the secret is loaded whenever a Cloud Run instance of your service is started. This happens all the time. So even if you don’t re-deploy your Cloud Run service yourself, the new value of the secret will eventually make it into your Cloud Run service.
Checkout more episodes of Serverless Expeditions → goo.gle/ServerlessExpeditions
Subscribe to Google Cloud Tech → goo.gle/GoogleCloudTech
#ServerlessExpeditions #ServerlessExpeditionsExtended #CloudRun
Product: Cloud Run, Secret Manager; fullname: Martin Omander;
Why it's here
1 person recommends this
What people say. Recommended as a guide to reading secrets from Secret Manager as environment variables in Cloud Run.
M
Martin Omanderon Stack Overflow • Recommends
On “How to use a Google Secret in a deployed Cloud Run Service (managed)?”
You can now read secrets from Secret Manager as environment variables in Cloud Run. This means you can audit your secrets, set permissions per secret, version secrets, etc, and your code doesn't have to change.
You can point to the secrets through the Cloud Console GUI (console.cloud.google.com) or make the configuration when you deploy your Cloud Run service from the command-line:
gcloud beta run deploy SERVICE --image IMAGE_URL --update-secrets=ENV_VAR_NAME=SECRET_NAME:VERSION
Six-minute video overview: link to this video
Detailed docs: https://cloud.google.com/run/docs/configuring/secrets