-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.tf
94 lines (84 loc) · 3.73 KB
/
main.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
locals {
name_prefix = var.cluster_name
pull_secret = var.pull_secret_path != null && var.pull_secret_path != "" ? file(var.pull_secret_path) : null
}
resource "azurerm_resource_group" "main" {
name = "${local.name_prefix}-rg"
location = var.location
}
resource "azurerm_virtual_network" "main" {
name = "${local.name_prefix}-vnet"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
address_space = [var.aro_virtual_network_cidr_block]
tags = var.tags
}
resource "azurerm_subnet" "control_plane_subnet" {
name = "${local.name_prefix}-cp-subnet"
resource_group_name = azurerm_resource_group.main.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = [var.aro_control_subnet_cidr_block]
service_endpoints = ["Microsoft.Storage", "Microsoft.ContainerRegistry"]
}
resource "azurerm_subnet" "machine_subnet" {
name = "${local.name_prefix}-machine-subnet"
resource_group_name = azurerm_resource_group.main.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = [var.aro_machine_subnet_cidr_block]
service_endpoints = ["Microsoft.Storage", "Microsoft.ContainerRegistry"]
}
resource "azurerm_network_security_group" "aro" {
name = "${local.name_prefix}-nsg"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
}
// TODO: lockdown for private clusters
resource "azurerm_network_security_rule" "aro_inbound_api" {
name = "${local.name_prefix}-inbound-api"
network_security_group_name = azurerm_network_security_group.aro.name
resource_group_name = azurerm_resource_group.main.name
priority = 120
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "6443"
source_address_prefix = "0.0.0.0/0"
destination_address_prefix = "*"
}
// TODO: lockdown for private clusters
resource "azurerm_network_security_rule" "aro_inbound_http" {
name = "${local.name_prefix}-inbound-http"
network_security_group_name = azurerm_network_security_group.aro.name
resource_group_name = azurerm_resource_group.main.name
priority = 500
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "80"
source_address_prefix = "0.0.0.0/0"
destination_address_prefix = "*"
}
// TODO: lockdown for private clusters
resource "azurerm_network_security_rule" "aro_inbound_https" {
name = "${local.name_prefix}-inbound-https"
network_security_group_name = azurerm_network_security_group.aro.name
resource_group_name = azurerm_resource_group.main.name
priority = 501
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "0.0.0.0/0"
destination_address_prefix = "*"
}
resource "azurerm_subnet_network_security_group_association" "control_plane" {
subnet_id = azurerm_subnet.control_plane_subnet.id
network_security_group_id = azurerm_network_security_group.aro.id
}
resource "azurerm_subnet_network_security_group_association" "machine" {
subnet_id = azurerm_subnet.machine_subnet.id
network_security_group_id = azurerm_network_security_group.aro.id
}