-
Notifications
You must be signed in to change notification settings - Fork 29
/
key_vault.tf
58 lines (47 loc) · 2.04 KB
/
key_vault.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (c) 2021 Microsoft
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Key Vault with VNET binding and Private Endpoint
resource "azurerm_key_vault" "aml_kv" {
name = "${var.prefix}-kv-${random_string.postfix.result}"
location = azurerm_resource_group.aml_rg.location
resource_group_name = azurerm_resource_group.aml_rg.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
network_acls {
default_action = "Deny"
ip_rules = []
virtual_network_subnet_ids = [azurerm_subnet.aml_subnet.id, azurerm_subnet.compute_subnet.id, azurerm_subnet.aks_subnet.id]
bypass = "AzureServices"
}
}
# DNS Zones
resource "azurerm_private_dns_zone" "kv_zone" {
name = "privatelink.vaultcore.azure.net"
resource_group_name = azurerm_resource_group.aml_rg.name
}
# Linking of DNS zones to Virtual Network
resource "azurerm_private_dns_zone_virtual_network_link" "kv_zone_link" {
name = "${random_string.postfix.result}_link_kv"
resource_group_name = azurerm_resource_group.aml_rg.name
private_dns_zone_name = azurerm_private_dns_zone.kv_zone.name
virtual_network_id = azurerm_virtual_network.aml_vnet.id
}
# Private Endpoint configuration
resource "azurerm_private_endpoint" "kv_pe" {
name = "${var.prefix}-kv-pe-${random_string.postfix.result}"
location = azurerm_resource_group.aml_rg.location
resource_group_name = azurerm_resource_group.aml_rg.name
subnet_id = azurerm_subnet.aml_subnet.id
private_service_connection {
name = "${var.prefix}-kv-psc-${random_string.postfix.result}"
private_connection_resource_id = azurerm_key_vault.aml_kv.id
subresource_names = ["vault"]
is_manual_connection = false
}
private_dns_zone_group {
name = "private-dns-zone-group-kv"
private_dns_zone_ids = [azurerm_private_dns_zone.kv_zone.id]
}
}