I want to use terraform to manage my Cloud Run deployments but the Cloud Run deployments depend on secrets. Therefore Secret Manager secrets have to be created by terraform beforehand but I do not want my secrets stored in variables.
What I have
- am using gcp cloud storage to store tfsate
- deploys cloud run that needs secrets
- secrets have to exist or cloud run fails to start
- can only use
google_secret_manager_secret_version
if the value is defined in tfvars - don't want secrets values in plain text in any local files
- creating
google_secret_manager_secret_version
with an initial random value, will replace onterrafrom apply
after manually changing secret to real value - can't only create
google_secret_manager_secret
without having agoogle_secret_manager_secret_version
because cloud run needs alatest
value to be present to be created.
All the tutroials I found use google_secret_manager_secret_version
with a hardcoded secret in variables. That is a NO, having secrets locally in files is a security problem.
The solution I would like to do is to have terraform create the secrets with random values and not touch them afterwards. Then I can replace them with real values through the GCP ui. This is not working because terraform wants to keep the secrets values in sync with the initialed random values. lifecycle ignore_changes
does not work because the secrets are never updated but deleted and created.
Has anybody come up with a good approach of using terraform to create a service that depends on secrets but not have to have secrets be defined in any local files?