Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform with Azure Key Vault to get secret value

Is there any way to get the value of a secret from Azure Key Vault?

Doesn't look like value gets exposed in the key vault secret object here.

like image 407
experimenter Avatar asked Oct 15 '17 03:10

experimenter


People also ask

How do you pull secrets from Azure key vault?

If you click on the current version, you can see the value you specified in the previous step. By clicking "Show Secret Value" button in the right pane, you can see the hidden value. You can also use Azure CLI, or Azure PowerShell to retrieve previously created secret.

How do I use Azure key vault with Terraform?

Inside the keyvault folder, create the variables.tf file to store variables used by the module: Then, create the main.tf to create the Azure Key Vault and policies, inside the keyvault folder: Finally, we create the ouput.tf file in the same folder used to return the values of the Terraform module.


1 Answers

Now you can do it with azurerm_key_vault_secret data source.

I'm enjoying without any scripting.

data "azurerm_key_vault_secret" "test" {
  name      = "secret-sauce"
  vault_uri = "https://rickslab.vault.azure.net/"
}

output "secret_value" {
  value = "${data.azurerm_key_vault_secret.test.value}"
}
like image 94
guitarrapc Avatar answered Nov 15 '22 18:11

guitarrapc