You'll create a scalable web application infrastructure in Azure using Terraform. The infrastructure will include a Virtual Machine Scale Set (VMSS) behind a load balancer with proper security and scaling configurations.
- Create a resource group in one of these regions:
- East US
- West Europe
- Southeast Asia Also create the validation rule that restrict other regions
- Create a VNet with two subnets:
- Application subnet (for VMSS)
- Management subnet (for future use)
- Configure an NSG that:
- Only allows traffic from the load balancer to VMSS
- Uses dynamic blocks for rule configuration
- Denies all other inbound traffic
- Set up a VMSS with:
- Ubuntu 20.04 LTS
- VM sizes with conditions based on environment(hint: use lookup function):
- Dev: Standard_B1s
- Stage: Standard_B2s
- Prod: Standard_B2ms
- Configure auto-scaling:
- Scale in when CPU < 10%
- Scale out when CPU > 80%
- Minimum instances: 2
- Maximum instances: 5
- Create an Azure Load Balancer:
- Public IP
- Backend pool connected to VMSS
- Health probe on port 80
- Create a terraform.tfvars file with:
- Environment name
- Region
- Resource name prefix
- Instance counts
- Network address spaces
- Implement locals block for:
- Common tags
- Resource naming convention
- Network configuration
- Use dynamic blocks for:
- NSG rules
- Load balancer rules