I'm moving chart deployments from Terraform to Helmfile. Terraform currently writes non-secret values to a file and creates a secret that workloads reference through an ExternalSecret. Are there other practical ways to connect the two?
How do you pass Terraform outputs and secrets to Helmfile?
Answers
That split is a reasonable place to start. Let Terraform produce a values file for infrastructure details, then have Helmfile read it when deploying the charts.
For the generated file, JSON can be easier to produce reliably than hand-built YAML. A small wrapper can convert it to YAML before Helmfile runs. Keep the interface narrow so chart configuration isn't tied to every Terraform output.
Reply to this answer
The ExternalSecret route makes sense for sensitive values, especially if the secret store is the handoff point rather than a generated values file. That keeps the secret material out of the values you pass to Helmfile.
One catch: creating the secret with Terraform can still put its value in Terraform state. Treat that state as sensitive and check whether Terraform needs to handle the secret value at all.
Reply to this answer
If you're open to changing the deployment model, consider Argo CD or Flux for workloads instead of Helmfile. Terraform can provision the infrastructure and bootstrap the controller, while the controller handles application deployments.
That doesn't eliminate the need to pass infrastructure settings and secrets along, but it gives cluster workloads a separate lifecycle from the infrastructure. It can also add another dependency when cluster configuration changes, so the split isn't free.
Reply to this answer
There are cases where keeping chart deployment in Terraform is perfectly practical. For a short-lived environment that needs to come up in one apply, having a single entry point can be convenient. For long-running workloads, think through how updates and lifecycle management will work before committing to it.
Reply to this answer
Add your answer
Answers are reviewed before publication.
_g52+ticketpulley.6:
Good point about state. Keeping secrets out of the generated file doesn't automatically keep them out of Terraform.