You deploy a Cloud Run service and configure an environment variable to pull a secret from Secret Manager. What happens if the secret is updated after deployment?
Think about how environment variables are loaded during service startup.
Cloud Run loads environment variables at startup. If a secret changes in Secret Manager, the running service does not see the update until redeployed or restarted.
You want a Cloud Function to read secrets from Secret Manager securely. Which IAM role should you assign to the Cloud Function's service account?
Consider the least privilege principle for reading secrets.
The role roles/secretmanager.secretAccessor allows reading secret payloads. Admin and viewer roles have broader or different permissions. secretVersionAdder is for adding versions, not reading.
You want to deploy a Cloud Run service and inject a secret named API_KEY from Secret Manager as an environment variable API_KEY. Which gcloud command is correct?
Check the gcloud flag that specifically injects secrets as environment variables.
The flag --set-secrets injects secrets from Secret Manager as environment variables. The syntax is ENV_VAR=SECRET_NAME:VERSION. Other flags are invalid or do not exist.
You have multiple microservices running on GKE and Cloud Run that need access to the same secrets. What is the best architecture to manage and secure these secrets?
Think about central management and least privilege access.
Secret Manager provides a secure, centralized way to store secrets. Granting each service's identity access follows best security practices. Environment variables and container images are less secure. Public buckets expose secrets to everyone.
You want to rotate secrets used as environment variables in Cloud Run services without causing downtime. Which approach follows best practices?
Consider how Cloud Run handles revisions and traffic splitting.
Cloud Run does not automatically refresh environment variables from secrets. Deploying a new revision with the updated secret and shifting traffic gradually avoids downtime and allows rollback if needed.