You can use Data Source: azurerm_key_vault_secret to access the value of the secret in an existing Key vault. Of course, the deployment that creates the Key vault and the secret must execute before the module.
If the two deployments are in the modules, then you need to define the output for the secret in the Key Vault deployment. Here is an example:
main.tf
module "keyvault" {
source = "./modules/keyvault"
...
}
module "other_deployment" {
source = ./modules/other_deployment
secret-password-1 = module.keyvault.secret-password-1
}
./modules/keyvault/main.tf
...
output "secret-password-1" {
value = azurerm_key_vault_secret.exxample.value
}
./modules/other_deployment/main.tf
variable "secret-password-1" {}
This example shows how you can quote the secret created in another module.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…