-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
110 lines (97 loc) · 3.04 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.63.0"
}
}
}
provider "azurerm" {
features {}
skip_provider_registration = "true"
}
resource "azurerm_virtual_network" "vnet-1" {
name = "vnet-1"
address_space = ["10.0.0.0/26"]
resource_group_name = var.rg
location = var.location
}
resource "azurerm_subnet" "subnet-1" {
name = "subnet-1"
resource_group_name = var.rg
virtual_network_name = azurerm_virtual_network.vnet-1.name
address_prefixes = ["10.0.0.0/28"]
}
resource "azurerm_subnet" "subnet-2" {
name = "subnet-2"
resource_group_name = var.rg
virtual_network_name = azurerm_virtual_network.vnet-1.name
address_prefixes = ["10.0.0.16/28"]
}
resource "azurerm_subnet" "subnet-3" {
name = "subnet-3"
resource_group_name = var.rg
virtual_network_name = azurerm_virtual_network.vnet-1.name
address_prefixes = ["10.0.0.32/28"]
}
resource "azurerm_subnet" "subnet-4" {
name = "subnet-4"
resource_group_name = var.rg
virtual_network_name = azurerm_virtual_network.vnet-1.name
address_prefixes = ["10.0.0.48/28"]
}
resource "azurerm_public_ip" "publiclb-ip" {
name = "publiclb-ip"
resource_group_name = var.rg
location = var.location
allocation_method = "Static"
}
resource "azurerm_lb" "publiclb" {
name = "publiclb"
resource_group_name = var.rg
location = var.location
frontend_ip_configuration {
name = "publiclb-ip-association"
public_ip_address_id = azurerm_public_ip.publiclb-ip.id
}
}
resource "azurerm_lb_backend_address_pool" "publiclb-backend" {
loadbalancer_id = azurerm_lb.publiclb.id
name = "publiclb-backend"
}
resource "azurerm_lb_nat_pool" "publiclb-nat-pool" {
resource_group_name = var.rg
loadbalancer_id = azurerm_lb.publiclb.id
name = "publiclb-nat-pool"
protocol = "Tcp"
frontend_port_start = 9000
frontend_port_end = 9002
backend_port = 80
frontend_ip_configuration_name = "publiclb-ip-association"
}
resource "azurerm_lb" "lb_interne" {
name = "lb_interne"
location = var.location
resource_group_name = var.rg
frontend_ip_configuration {
name = "lb_interne_frontend"
subnet_id = azurerm_subnet.subnet-3.id
}
tags = {
Brief = var.brief_tag
Owner = "Jess"
}
}
resource "azurerm_lb_backend_address_pool" "lb_interne_backend" {
loadbalancer_id = azurerm_lb.lb_interne.id
name = "BackEndAddressPool"
}
resource "azurerm_lb_rule" "lb_internerule" {
loadbalancer_id = azurerm_lb.lb_interne.id
name = "LBRule"
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "lb_interne_frontend"
backend_address_pool_ids = [azurerm_lb_backend_address_pool.lb_interne_backend.id]
}