We’re a Core Services team, starting to stand up HCP Vault for other teams to use. I’m leaning heavily on templated ACL policies and for_each loops in my TF files. One of the things I want to do for each team/application being onboarded is to provide them with security boundaries within their engine - eg the MobileApp team will get a kv-v2 engine, with paths at /secrets/MobileApp/dev , /secrets/MobileApp/prod, etc. We’ll make AppRole entities that only get access to /dev and /prod , using templated ACLs.
Terraform won’t let me make empty paths, so I create a dummy “example” secret under each path, looks like this
resource "vault_kv_secret_v2" "example" {
for_each = {
for app in local.app_boundaries :
"${app.app_name}/${app.boundary}" => app if app.engine_type == "kv-v2"
}
provider = vault
mount = vault_mount.engine[each.value.app_name].path
name = "${each.value.boundary}/example"
data_json = jsonencode(
{
"${each.value.boundary}-foo" = "${each.value.boundary}-bar"
}
)
depends_on = [null_resource.kv1_to_kv2_migration]
}
When the using teams then start to make their own secrets in the future, via the UI inside our HCP instance, how do I keep terraform from deleting their newly-created secrets? I’m currently just running OSS TF from my own desktop but if we start using HCP TF, that has drift detection and I’m unsure how to do this.
I know I can do lifecycle { prevent_destroy = true }
but I don’t care if they do delete their “example” secret, and I don’t see how that prevents items manually created from being destroyed.