Day 13: Conditional Expressions & Logic
Welcome to Day 13 - Today’s topic is a big one — Conditional Logic in Terraform.By the end of this lesson, you’ll be able to make your Terraform configurations smart, flexible, and environment-aware—meaning your infrastructure can automatically adjus...
stackopsdiary.site13 min read
Thu Kha Kyawe
Cloud Engineer | Site Reliability Engineer
Thank you! I see there is minor error.
Add the following EIP resource to your main.tf file, preferably before the NAT Gateway resource:
Elastic IPs for NAT Gateways (conditional)
resource "aws_eip" "nat" { count = local.create_nat_gateway ? local.az_count : 0 domain = "vpc"
tags = { Name = "${var.project_name}-${var.environment}-nat-eip-${count.index + 1}" } }