0

How can I use a value passed into a Data Source? It seems like there is no issue in snowflake_user.userSVC_db as it properly states that I would like to check whether or not a Secret within Azure Key Vault with name INGEROIS_ABB_PBI_SVC exists

resource "snowflake_user" "userSVC_db" {
  for_each             = var.user_collection
  name                 = each.key
  ...
  password             =  ( each.value.password_overwrite == false ? random_password.password[ index(keys(var.user_collection), each.key) ].result : (                                                           
                            each.value.password_overwrite == true  ? random_password.password-overwrite.result : (
                            each.value.password_overwrite == null ? data.azurerm_key_vault_secret.secret_check["PM-${replace(each.value.name, "_", "-")}"].value : null
  )
 )
)
}

The problem is that I do not know how I am suppose to express that a passed value should be assigned to property name instead of looping through whole collection:

data "azurerm_key_vault_secret" "secret_check" {
  for_each     = var.user_collection
  name         = "PM-${replace(each.value.name, "_", "-")}"
  key_vault_id = module.variables.keyVault-id
}

1 Answer 1

1

You can reference a key vault secret ID with the following syntax:

azurerm_key_vault_secret.secret_checkSecrets["KEY-VALUE-FROM-user_collection"].id

The value "KEY-VALUE-FROM-user_collection" is from your loop var.user_collection

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.