-
Notifications
You must be signed in to change notification settings - Fork 0
/
private_provision.tf
98 lines (80 loc) · 3.08 KB
/
private_provision.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "RG" {
name = format("%s-%s",upper(var.az_projname),"RG")
location = "West Europe"
}
resource "azurerm_kubernetes_cluster" "kubecluster" {
name = format("%s-%s",var.az_projname, "kc")
resource_group_name = azurerm_resource_group.RG.name
location = azurerm_resource_group.RG.location
dns_prefix = format("%s-%s",var.az_projname, "kc")
private_cluster_enabled = true
identity {
type = "SystemAssigned"
}
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
}
tags = {
Environment = azurerm_resource_group.RG.name
}
}
resource "azurerm_virtual_network" "vnet" {
name = format("%s-%s",var.az_projname, "vn")
address_space = ["10.1.0.0/16"]
location = azurerm_resource_group.RG.location
resource_group_name = azurerm_resource_group.RG.name
}
resource "azurerm_subnet" "service_subnet" {
name = format("%s-%s",var.az_projname, "servicenet")
resource_group_name = azurerm_resource_group.RG.name
virtual_network_name = azurerm_virtual_network.vnet.name
address_prefixes = ["10.1.1.0/24"]
#enforce_private_link_service_network_policies = true
}
resource "azurerm_subnet" "endpoint_subnet" {
name = format("%s-%s",var.az_projname, "endpointnet")
resource_group_name = azurerm_resource_group.RG.name
virtual_network_name = azurerm_virtual_network.vnet.name
address_prefixes = ["10.1.2.0/24"]
enforce_private_link_endpoint_network_policies = true
}
resource "azurerm_container_registry" "cont_rgy" {
name = format("%s%s",var.az_projname, "cregistry")
resource_group_name = azurerm_resource_group.RG.name
location = azurerm_resource_group.RG.location
admin_enabled = false
public_network_access_enabled = false
sku = "Premium"
}
resource "azurerm_private_dns_zone" "private_dz" {
name = "privatelink.azurecr.io"
resource_group_name = azurerm_resource_group.RG.name
}
resource "azurerm_private_dns_a_record" "dns_a1" {
name = lower(azurerm_container_registry.cont_rgy.name)
zone_name = azurerm_private_dns_zone.private_dz.name
resource_group_name = azurerm_resource_group.RG.name
ttl = 10
records = ["10.1.2.5"]
}
resource "azurerm_private_endpoint" "private_endpoint" {
name = format("%s-%s", var.az_projname, "endpoint")
resource_group_name = azurerm_resource_group.RG.name
location = azurerm_resource_group.RG.location
subnet_id = azurerm_subnet.endpoint_subnet.id
private_dns_zone_group {
name = azurerm_private_dns_zone.private_dz.name
private_dns_zone_ids = [azurerm_private_dns_zone.private_dz.id]
}
private_service_connection {
name = format("%s-%s", var.az_projname, "psc")
private_connection_resource_id = azurerm_container_registry.cont_rgy.id
is_manual_connection = false
subresource_names = ["registry"]
}
}