Menu

1 / 2

Fully Migrate Secrets Out Of Terraform Module State Without Breaking Existing Users

DEV Community·drewmullen·7 months ago
#eR0ah5SD
#devops#security#terraform#tutorial#legacy
Reading 0:00
15s threshold

A few weeks ago I published a similar blog that shows how you can update your modules to optionally utilize ephemeral secrets, removing secrets from state for all new deployments. However, to maintain totally programmatic, older deployments still retained the secret.

This blog explores a method to fully remove secrets from state, even on old deployments. However, it requires manual effort on behalf of users and involves some risk.

Setup

V1 of your module had a resource which introduced a secret into state:

resource "tls_private_key" "legacy" { algorithm = "RSA" rsa_bits = 4096 }

resource "vault_kv_secret_v2" "legacy" { mount = "kvv2" name = "mytls" data_json = jsonencode ({ private_key = tls_private_key . legacy .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.