This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
92 lines (77 loc) · 3.46 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
terraform {
required_version = ">= 0.11"
}
locals {
environment = "${terraform.workspace == "default" ? "test" : terraform.workspace}"
}
data "azurerm_public_ip" "appgw_pip" {
name = "${var.name_prefix}-app-gw-public-ip-${local.environment}"
resource_group_name = "${var.create_new_rg == "true" ? "${element(concat(azurerm_resource_group.test.*.name, list("")), 0)}" : var.existing_rg}"
}
resource "azurerm_resource_group" "test" {
name = "${var.new_rg_name}"
location = "${var.location}"
count = "${var.create_new_rg == "true" ? 1 : 0}"
tags = {
Environment = "${local.environment}"
ManagedBy = "TF"
}
}
resource "azurerm_subnet" "appgw_subnet" {
name = "${var.name_prefix}-appgw-subnet-${local.environment}"
resource_group_name = "${var.create_new_rg == "true" ? "${element(concat(azurerm_resource_group.test.*.name, list("")), 0)}" : var.existing_rg}"
virtual_network_name = "${var.existing_vnet_name}"
address_prefix = "${var.app_gw_subnet_adr_prefix}"
}
resource "azurerm_public_ip" "appgw_pip" {
name = "${var.name_prefix}-app-gw-public-ip-${local.environment}"
resource_group_name = "${var.create_new_rg == "true" ? "${element(concat(azurerm_resource_group.test.*.name, list("")), 0)}" : var.existing_rg}"
public_ip_address_allocation = "static"
location = "${var.location}"
}
resource "azurerm_application_gateway" "application_gateway" {
name = "${var.name_prefix}-application-gateway-${local.environment}"
resource_group_name = "${var.create_new_rg == "true" ? "${element(concat(azurerm_resource_group.test.*.name, list("")), 0)}" : var.existing_rg}"
location = "${var.location}"
sku {
name = "${lookup(var.appgw_available_sku_names, var.app_gw_sku_name)}"
tier = "${lookup(var.appgw_available_sku_tiers, var.app_gw_sku_tier)}"
capacity = "${var.app_gw_sku_capacity}"
}
gateway_ip_configuration {
name = "${var.name_prefix}-appgw-ipconfiguration"
subnet_id = "${var.existing_vnet_id}/subnets/${azurerm_subnet.appgw_subnet.name}"
}
frontend_port {
name = "${var.existing_vnet_name}-feport"
port = "${var.app_gw_frontend_port}"
}
frontend_ip_configuration {
name = "${var.existing_vnet_name}-feip"
private_ip_address_allocation = "${var.private_ip_allocation}"
public_ip_address_id = "${azurerm_public_ip.appgw_pip.id}"
}
backend_address_pool {
name = "${var.existing_vnet_name}-beap"
}
backend_http_settings {
name = "${var.existing_vnet_name}-be-htst"
cookie_based_affinity = "${var.cookie_based_affinity}"
port = "${var.app_gw_backend_port}"
protocol = "${var.app_gw_backend_protocol}"
request_timeout = 1
}
http_listener {
name = "${var.existing_vnet_name}-httplstn"
frontend_ip_configuration_name = "${var.existing_vnet_name}-feip"
frontend_port_name = "${var.existing_vnet_name}-feport"
protocol = "${var.app_gw_backend_protocol}"
}
request_routing_rule {
name = "${var.existing_vnet_name}-rqrt"
rule_type = "Basic"
http_listener_name = "${var.existing_vnet_name}-httplstn"
backend_address_pool_name = "${var.existing_vnet_name}-beap"
backend_http_settings_name = "${var.existing_vnet_name}-be-htst"
}
}