Home > Mobile >  how do i substitute text for a variable in a terraform?
how do i substitute text for a variable in a terraform?

Time:07-27

I'm new to terraform and wanted to substitute the value devcert below for a variable value called env, how do i format the below to include the variable value instead of devcert?

pfx_blob = data.azurerm_key_vault_secret.devcert.value

// Get Certificate from External KeyVault

resource "azurerm_app_service_certificate" "cert" {
  name                = "sslCertificate"
  resource_group_name = "rg1"
  location            = "uk west"
  pfx_blob            = data.azurerm_key_vault_secret.devcert.value

CodePudding user response:

You can't do that. Such operation is not supported in terraform. Instead you should use for_each to create multiple instances of azurerm_key_vault_secret, rather then fully separate data sources. Then you can reference it using:

pfx_blob = data.azurerm_key_vault_secret.devcert["myinstance"].value
  • Related