Build Secret Manager secret configurations with replication, rotation, and CMEK encryption.
Last verified: May 2026
Build Secret Manager secret configurations with replication, rotation policies, and CMEK encryption.
Required Fields
namereplicationOutput will appear here...Google Cloud Secret Manager provides a centralized, secure store for API keys, passwords, certificates, and other sensitive data with versioning, automatic rotation, and fine-grained IAM access control. Creating secrets involves specifying replication policies (automatic or user-managed across specific regions), labels, expiration times, rotation schedules, and Pub/Sub notification topics for secret events. This builder helps you configure secrets with correct replication policies, IAM bindings, rotation schedules, and consumer-side access patterns, generating configurations for gcloud CLI, Terraform, and client library code.
Your team is migrating database passwords from environment variables in Cloud Run services to Secret Manager. The builder generates: secrets with automatic replication, labels for environment/service, IAM bindings granting the Cloud Run service account Secret Accessor role on specific secrets only. The Cloud Run code uses 'projects/X/secrets/Y/versions/latest' to always fetch the current version. When DB passwords need rotation, the ops team adds a new version — services pick it up on next request, no Cloud Run redeploy needed.
Always use 'latest' alias in application code, not specific version numbers. When you rotate the secret (creating a new version), apps automatically pick up the new value on next fetch. Hardcoding version numbers turns rotation into a deploy-required operation, which defeats the point of having rotation.
User-managed replication is required for compliance scenarios but adds complexity. For the 95% case where data residency isn't a hard requirement, automatic replication is dramatically simpler — and Google manages region selection for optimal availability.
Secret Manager doesn't generate new secret values during rotation — it just notifies your rotation function via Pub/Sub. You still have to write the rotation logic (generate new credentials with the upstream service, write to Secret Manager). This is more work but more flexible than AWS Secrets Manager's built-in rotators.
The builder constructs Secret Manager secret resources with: name, replication policy (automatic or user-managed with region list and optional CMEK), labels, expiration time, rotation schedule (rotation_period and next_rotation_time) and Pub/Sub notification topic. Output is generated as gcloud secrets create commands and Terraform google_secret_manager_secret resources. It also generates the prerequisite IAM bindings (Secret Accessor for consumers, Secret Manager Admin for ops).
Was this tool helpful?
Disclaimer: This tool runs entirely in your browser. No data is sent to our servers. Always verify outputs before using them in production. AWS, Azure, and GCP are trademarks of their respective owners.