Complete the code to enable cross-zone load balancing on the AWS Elastic Load Balancer.
resource "aws_lb" "example" { name = "example-lb" internal = false load_balancer_type = "application" subnets = ["subnet-12345678", "subnet-87654321"] enable_cross_zone_load_balancing = [1] }
Setting enable_cross_zone_load_balancing to true enables cross-zone load balancing on the AWS load balancer.
Complete the code to create a target group with cross-zone load balancing enabled on the load balancer.
resource "aws_lb_target_group" "example_tg" { name = "example-tg" port = 80 protocol = "HTTP" vpc_id = "vpc-12345678" [1] = true }
The correct attribute to enable cross-zone load balancing on the target group is enable_cross_zone_load_balancing.
Fix the error in the code to correctly enable cross-zone load balancing for the AWS Classic Load Balancer.
resource "aws_elb" "example" { name = "example-classic-lb" availability_zones = ["us-west-2a", "us-west-2b"] [1] = true }
enable_cross_zone_load_balancing which is for ALB/NLB.For AWS Classic Load Balancer, the attribute to enable cross-zone load balancing is cross_zone_load_balancing.
Fill both blanks to configure an Application Load Balancer with cross-zone load balancing enabled and access logs turned on.
resource "aws_lb" "example" { name = "example-alb" load_balancer_type = "application" subnets = ["subnet-11111111", "subnet-22222222"] [1] = true access_logs { [2] = "my-log-bucket" } }
access_log_bucket instead of bucket inside access_logs.To enable cross-zone load balancing, use enable_cross_zone_load_balancing. For access logs, the bucket name is set with bucket inside the access_logs block.
Fill all three blanks to create a Network Load Balancer with cross-zone load balancing enabled, health check configured, and a target group attached.
resource "aws_lb" "nlb" { name = "example-nlb" load_balancer_type = "network" subnets = ["subnet-aaaaaaa", "subnet-bbbbbbb"] [1] = true } resource "aws_lb_target_group" "tg" { name = "example-tg" port = 80 protocol = "TCP" vpc_id = "vpc-abcdef12" health_check { [2] = "/" [3] = 30 } }
cross_zone_load_balancing for NLB instead of enable_cross_zone_load_balancing.For Network Load Balancer, cross-zone load balancing is enabled with enable_cross_zone_load_balancing. Health check path and interval configure the check URL and frequency.