I want to have a yaml pipeline that pulls all my secrets out of an azure devops library and pushes them into key vault as secrets using terraform.
I’m already able to pull values out of a library and access them inside terraform as environment variable by doing what is below for example…
tenantId=$(tf-sp-tenant-id)
echo "##vso[task.setvariable variable=TF_VAR_tenant_id]$tenantId"
I want to do something like this but not sure how to name them all in devops library so they all map automatically to the secrets variable below.. and then how to pass them all into a module that has map(string) as a input variable?
resource "azurerm_key_vault_secret" "example" {
for_each = var.secrets
name = each.key
value = each.value
key_vault_id = azurerm_key_vault.example.id
}
variable "tenant_id" {
description = "The Tenant ID for the Azure Key Vault"
}
variable "secrets" {
type = map(string)
description = "A map of secrets to store in the Azure Key Vault"
}