The terraform code creates an azure key vault secret successfully during the first apply, but with consecutive applies, it still is trying to update the secret because of the changes in the expiration time.
resource "azurerm_key_vault_secret" "supportedTen" {
name = "supportedTen"
value = var.supportedTen
key_vault_id = azurerm_key_vault.vault.id
expiration_date = timeadd(timestamp(), "2160h")
depends_on = [azurerm_key_vault_access_policy.vault]
}
2nd terraform apply onwards-
# azurerm_key_vault_secret.supportedTenants will be updated in-place
~ resource "azurerm_key_vault_secret" "supportedTen" {
~ expiration_date = "2021-10-10T19:45:05Z" -> (known after apply)
id = "https://uri/secrets/supportedTen/abcde-secret-version"
key_vault_id = "/subscriptions/subscriptionid/resourceGroups/resourcegroup--id/providers/Microsoft.KeyVault/vaults/test-kv-dev"
name = "supportedTenants"
tags = {}
value = (sensitive value)
version = "abcde-secret-version"
}
Is there any way I can put a condition if the expiration time is not expired or the secret version value is not empty(""), don't update the azure key vault secret resource?