-
Notifications
You must be signed in to change notification settings - Fork 3
/
azure_remote_main.tf
137 lines (120 loc) · 5.07 KB
/
azure_remote_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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Used to manage remote Azure region
variable "azure_remote_region" {
default = "UK South"
}
# Used to manage remote Azure region
variable "num_of_remote_azure_private_agents" {
default = "1"
}
# Used to manage remote Azure region
variable "num_of_remote_azure_public_agents" {
default = "1"
}
# Create a resource group
resource "azurerm_resource_group" "dcos_remote" {
name = "dcos-remote-${data.template_file.cluster-name.rendered}"
location = "${var.azure_remote_region}"
tags {
Name = "${coalesce(var.owner, data.external.whoami.result["owner"])}"
expiration = "${var.expiration}"
}
}
# Create a virtual network in the web_servers resource group
resource "azurerm_virtual_network" "vnet_remote" {
name = "vnet_remote-${data.template_file.cluster-name.rendered}"
address_space = ["10.33.0.0/16"]
location = "${var.azure_remote_region}"
resource_group_name = "${azurerm_resource_group.dcos_remote.name}"
tags {
Name = "${coalesce(var.owner, data.external.whoami.result["owner"])}"
expiration = "${var.expiration}"
}
}
resource "azurerm_subnet" "public_remote" {
name = "public_remote"
address_prefix = "10.33.0.0/22"
virtual_network_name = "${azurerm_virtual_network.vnet_remote.name}"
resource_group_name = "${azurerm_resource_group.dcos_remote.name}"
route_table_id = "${azurerm_route_table.private_remote.id}"
}
resource "azurerm_subnet" "private_remote" {
name = "private_remote"
address_prefix = "10.33.4.0/22"
virtual_network_name = "${azurerm_virtual_network.vnet_remote.name}"
resource_group_name = "${azurerm_resource_group.dcos_remote.name}"
route_table_id = "${azurerm_route_table.private_remote.id}"
}
# Public Subnet Security Groups
resource "azurerm_network_security_group" "public_subnet_security_group_remote" {
name = "${data.template_file.cluster-name.rendered}-master-security-group"
location = "${var.azure_remote_region}"
resource_group_name = "${azurerm_resource_group.dcos_remote.name}"
tags {
Name = "${coalesce(var.owner, data.external.whoami.result["owner"])}"
expiration = "${var.expiration}"
}
}
# Public Subnet NSG Rule
resource "azurerm_network_security_rule" "master-sshRule_remote" {
name = "sshRule"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "*"
source_port_range = "*"
destination_port_range = "22"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "${azurerm_resource_group.dcos_remote.name}"
network_security_group_name = "${azurerm_network_security_group.public_subnet_security_group_remote.name}"
}
resource "azurerm_network_security_rule" "public-subnet-httpRule_remote" {
name = "HTTP"
priority = 110
direction = "Inbound"
access = "Allow"
protocol = "*"
source_port_range = "80"
destination_port_range = "80"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "${azurerm_resource_group.dcos_remote.name}"
network_security_group_name = "${azurerm_network_security_group.public_subnet_security_group_remote.name}"
}
# Public Subnet NSG Rule
resource "azurerm_network_security_rule" "public-subnet-httpsRule_remote" {
name = "HTTPS"
priority = 120
direction = "Inbound"
access = "Allow"
protocol = "*"
source_port_range = "443"
destination_port_range = "443"
source_address_prefix = "*"
destination_address_prefix = "*"
resource_group_name = "${azurerm_resource_group.dcos_remote.name}"
network_security_group_name = "${azurerm_network_security_group.public_subnet_security_group_remote.name}"
}
output "ssh_user_remote" {
value = "${module.azure-tested-oses.user}"
}
resource "azurerm_route_table" "private_remote" {
# TODO(mbernadin): current data azurerm_subnet does not support associating
# existing resources with routing tables. Creating this one to make hybrid cloud
# work explicitly
name = "dcos_remote_cisco_vpn_route_table"
location = "${var.azure_remote_region}"
resource_group_name = "${azurerm_resource_group.dcos_remote.name}"
route {
name = "RemoteCiscoRouter"
address_prefix = "${aws_vpc.default.cidr_block}"
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = "${module.aws_azure_cisco_vpn_connecter.private_azure_csr_private_ip}"
}
route {
name = "RemoteCiscoRouter-Spoke"
address_prefix = "${aws_vpc.bursted_region.cidr_block}"
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = "${module.remote_aws_azure_cisco_vpn_connecter.private_azure_csr_private_ip}"
}
}