Create a load balancer with an availability set in the backend pool using the Terraform.
This Terraform task creates a load balancer and availability set.
A Resource Group, Storage Account, virtual machines in an availability set, load balancer with 80 (HTTP) and 443 (HTTPS) rules, Virtual Network, 3 Subnets, 2 data disks, 2 os disks, a Public IP.
variable "arm_region"
description = "The Azure region to create things in."
variable "arm_vm_admin_password"
description = "Passwords for the root user in VMs."
variable "arm_frontend_instances"
description = "Number of front instances"
Resource group name is "oguzhanRG" in the "West US" location.
Storage account name is "oaydoganstorageacc" in the Resource group we just created.
Virtual network name is "tf-vnet"
Subnet names are "frontend", "backend" and "dmz"
Virtual Machines in availability set name is "tf-avail-set".
Load Balancer name is "tf-lb"
Rule 1 : resource "azurerm_lb_probe" "port80" {
name = "tf-lb-rule-80"
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "default"
Rule 2 : resource "azurerm_lb_rule" "port443" {
name = "tf-lb-rule-443"
protocol = "Tcp"
frontend_port = 443
backend_port = 443
frontend_ip_configuration_name = "default"
Health probe for HTTP
Health proble for HTTPS
Public IP name is "tf-public-ip", allocation_method set as = "Static"
Backend pool for availability set.
Outputs :
output "frontend_id"
output "backend_id"
output "dmz_id"
output "load_balancer_ip"
Allow me to export structured data about my resources.
We will keep our tfstate file in the container, named "oaydogancontainer"