Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
bernadinm committed Sep 11, 2018
1 parent cf2d9a2 commit 1eff00d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
43 changes: 21 additions & 22 deletions lb-master.tf
Original file line number Diff line number Diff line change
@@ -1,74 +1,73 @@
# Public IP addresses for the Public Front End load Balancer
resource "azurerm_public_ip" "master_load_balancer_public_ip" {
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-master-lb-ip"
name = "${format(var.hostname_format, var.name_prefix)}-master-lb-ip"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
public_ip_address_allocation = "dynamic"
domain_name_label = "master-pub-lb-${format(var.hostname_format, count.index + 1, var.name_prefix)}"
domain_name_label = "master-pub-lb-${format(var.hostname_format, var.name_prefix)}"

tags = "${merge(var.tags, map("Name", format(var.hostname_format, (count.index + 1), var.location, var.name_prefix),
tags = "${merge(var.tags, map("Name", format(var.hostname_format, var.location, var.name_prefix),
"Cluster", var.name_prefix))}"
}

# Public IP addresses for the Public Front End load Balancer
resource "azurerm_public_ip" "master_public_ip" {
count = "${var.dcos_role == "master" ? 1 : 0 }"
count = "${var.num_of_masters}"
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-master-pub-ip-${count.index + 1}"
name = "${format(var.hostname_format, var.name_prefix)}-master-pub-ip"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
public_ip_address_allocation = "dynamic"
domain_name_label = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-master-${count.index + 1}"
domain_name_label = "${format(var.hostname_format, var.name_prefix)}-master"

tags = "${merge(var.tags, map("Name", format(var.hostname_format, (count.index + 1), var.location, var.name_prefix),
tags = "${merge(var.tags, map("Name", format(var.hostname_format, var.location, var.name_prefix),
"Cluster", var.name_prefix))}"
}

# Front End Load Balancer
resource "azurerm_lb" "master_public_load_balancer" {
count = "${var.dcos_role == "master" ? 1 : 0 }"
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-pub-mas-elb"
name = "${format(var.hostname_format, var.name_prefix)}-pub-mas-elb"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"

frontend_ip_configuration {
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public-ip-config"
name = "${format(var.hostname_format, var.name_prefix)}-public-ip-config"
public_ip_address_id = "${azurerm_public_ip.master_load_balancer_public_ip.id}"
}

tags = "${merge(var.tags, map("Name", format(var.hostname_format, (count.index + 1), var.location, var.name_prefix),
tags = "${merge(var.tags, map("Name", format(var.hostname_format, var.location, var.name_prefix),
"Cluster", var.name_prefix))}"
}

# Internal Private Front End Load Balancer
resource "azurerm_lb" "master_internal_load_balancer" {
count = "${var.dcos_role == "master" ? 1 : 0 }"
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-int-master-elb"
name = "${format(var.hostname_format, var.name_prefix)}-int-master-elb"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"

frontend_ip_configuration {
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-private-ip-config"
name = "${format(var.hostname_format, var.name_prefix)}-private-ip-config"
subnet_id = "${var.subnet_id}"
private_ip_address_allocation = "dynamic"
}

tags = "${merge(var.tags, map("Name", format(var.hostname_format, (count.index + 1), var.location, var.name_prefix),
tags = "${merge(var.tags, map("Name", format(var.hostname_format, var.location, var.name_prefix),
"Cluster", var.name_prefix))}"
}

# Back End Address Pool for Public and Private Loadbalancers
resource "azurerm_lb_backend_address_pool" "public_master_backend_pool" {
count = "${var.dcos_role == "master" ? 1 : 0 }"
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public_backend_address_pool"
name = "${format(var.hostname_format, var.name_prefix)}-public_backend_address_pool"
resource_group_name = "${var.resource_group_name}"
loadbalancer_id = "${azurerm_lb.master_public_load_balancer.id}"
}

# Back End Address Pool for Private Loadbalancers
resource "azurerm_lb_backend_address_pool" "private_master_backend_pool" {
count = "${var.dcos_role == "master" ? 1 : 0 }"
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-internal_backend_address_pool"
name = "${format(var.hostname_format, var.name_prefix)}-internal_backend_address_pool"
resource_group_name = "${var.resource_group_name}"
loadbalancer_id = "${azurerm_lb.master_internal_load_balancer.id}"
}
Expand All @@ -82,7 +81,7 @@ resource "azurerm_lb_rule" "public_load_balancer_http_rule" {
protocol = "Tcp"
frontend_port = "80"
backend_port = "80"
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-public-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.public_master_backend_pool.id}"
probe_id = "${azurerm_lb_probe.load_balancer_http_probe.id}"
depends_on = ["azurerm_lb_probe.load_balancer_http_probe"]
Expand All @@ -97,7 +96,7 @@ resource "azurerm_lb_rule" "public_load_balancer_https_rule" {
protocol = "Tcp"
frontend_port = 443
backend_port = 443
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-public-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.public_master_backend_pool.id}"
probe_id = "${azurerm_lb_probe.load_balancer_https_probe.id}"
depends_on = ["azurerm_lb_probe.load_balancer_https_probe"]
Expand All @@ -112,7 +111,7 @@ resource "azurerm_lb_rule" "private_load_balancer_http_rule" {
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-private-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-private-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.private_master_backend_pool.id}"
}

Expand All @@ -125,7 +124,7 @@ resource "azurerm_lb_rule" "private_load_balancer_https_rule" {
protocol = "Tcp"
frontend_port = 443
backend_port = 443
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-private-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-private-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.private_master_backend_pool.id}"
}

Expand All @@ -138,7 +137,7 @@ resource "azurerm_lb_rule" "private_load_balancer_mesos_http_rule" {
protocol = "Tcp"
frontend_port = 5050
backend_port = 5050
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-private-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-private-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.private_master_backend_pool.id}"
}

Expand All @@ -151,7 +150,7 @@ resource "azurerm_lb_rule" "private_load_balancer_exhibitor_http_rule" {
protocol = "Tcp"
frontend_port = 8181
backend_port = 8181
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-private-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-private-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.private_master_backend_pool.id}"
}

Expand All @@ -164,7 +163,7 @@ resource "azurerm_lb_rule" "private_load_balancer_marathon_https_rule" {
protocol = "Tcp"
frontend_port = 8080
backend_port = 8080
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-private-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-private-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.private_master_backend_pool.id}"
}

Expand Down
18 changes: 9 additions & 9 deletions lb-public-agent.tf
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# Public IP addresses for the Public Front End load Balancer
resource "azurerm_public_ip" "public_agent_load_balancer_public_ip" {
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public-lb-ip"
name = "${format(var.hostname_format, var.name_prefix)}-public-lb-ip"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
public_ip_address_allocation = "dynamic"
domain_name_label = "public-agent-${format(var.hostname_format, count.index + 1, var.name_prefix)}"
domain_name_label = "public-agent-${format(var.hostname_format, var.name_prefix)}"

tags = "${merge(var.tags, map("Name", format(var.hostname_format, (count.index + 1), var.location, var.name_prefix),
tags = "${merge(var.tags, map("Name", format(var.hostname_format, var.location, var.name_prefix),
"Cluster", var.name_prefix))}"
}

# Front End Load Balancer
resource "azurerm_lb" "public_agent_public_load_balancer" {
count = "${var.dcos_role == "public-agent" ? 1 : 0 }"
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-pub-agent-elb"
name = "${format(var.hostname_format, var.name_prefix)}-pub-agent-elb"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"

frontend_ip_configuration {
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public-agent-ip-config"
name = "${format(var.hostname_format, var.name_prefix)}-public-agent-ip-config"
public_ip_address_id = "${azurerm_public_ip.public_agent_load_balancer_public_ip.id}"
}

tags = "${merge(var.tags, map("Name", format(var.hostname_format, (count.index + 1), var.location, var.name_prefix),
tags = "${merge(var.tags, map("Name", format(var.hostname_format, var.location, var.name_prefix),
"Cluster", var.name_prefix))}"
}

# Back End Address Pool for Public and Private Loadbalancers
resource "azurerm_lb_backend_address_pool" "external_public_agent_backend_pool" {
count = "${var.dcos_role == "public-agent" ? 1 : 0 }"
name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public_backend_address_pool"
name = "${format(var.hostname_format, var.name_prefix)}-public_backend_address_pool"
resource_group_name = "${var.resource_group_name}"
loadbalancer_id = "${azurerm_lb.public_agent_public_load_balancer.id}"
}
Expand All @@ -43,7 +43,7 @@ resource "azurerm_lb_rule" "agent_public_load_balancer_http_rule" {
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public-agent-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-public-agent-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.external_public_agent_backend_pool.id}"
probe_id = "${azurerm_lb_probe.agent_load_balancer_http_probe.id}"
depends_on = ["azurerm_lb_probe.agent_load_balancer_http_probe"]
Expand All @@ -58,7 +58,7 @@ resource "azurerm_lb_rule" "agent_public_load_balancer_https_rule" {
protocol = "Tcp"
frontend_port = 443
backend_port = 443
frontend_ip_configuration_name = "${format(var.hostname_format, count.index + 1, var.name_prefix)}-public-agent-ip-config"
frontend_ip_configuration_name = "${format(var.hostname_format, var.name_prefix)}-public-agent-ip-config"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.external_public_agent_backend_pool.id}"
probe_id = "${azurerm_lb_probe.agent_load_balancer_https_probe.id}"
depends_on = ["azurerm_lb_probe.agent_load_balancer_https_probe"]
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variable "name_prefix" {}

# Format the hostname inputs are index+1, region, name_prefix
variable "hostname_format" {
default = "lb-%[1]d-%[2]s"
default = "lb-%[2]s"
}

# Name of the azure resource group
Expand Down

0 comments on commit 1eff00d

Please sign in to comment.