Terraform - 在Azure keyvault里面添加secrets

Terraform - 在Azure keyvault里面添加secrets

代码片段:

  • 使用data来访问已经存在的 keyvault
  • 创建azurerm_key_vault_secret资源,并且,要把key_vault_id指定为keyvault data source的id.
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.76.0"
    }
  }
}

provider "azurerm" {
  features {
    key_vault {
      purge_soft_delete_on_destroy = true
    }
  }
}

data "azurerm_key_vault" "azvault" {
  name                = "vault1"
  resource_group_name = "myrg"  
}

resource "azurerm_key_vault_secret" "secret" {
  name         = "secretname"
  value        = "secretvalue"
  key_vault_id = data.azurerm_key_vault.azvault.id
}

翻译:https://www.ntweekly.com/2021/02/02/add-a-secret-to-azure-key-vault-with-terraform/

你可能感兴趣的:(Terraform,Azure,terraform,azure,keyvault)