According to https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#specifying-private-ip-addresses-for-an-internal-facing-load-balancer, the private_ipv4_address is only applicable to internal-facing NLB. Which is not entirely true, according to official AWS Getting started guide:
By default, AWS assigns an IPv4 address to each load balancer node from the subnet for its Availability Zone. Alternatively, when you create an internet-facing load balancer, you can select an Elastic IP address for each Availability Zone. This provides your load balancer with static IP addresses.
EIP can be assigned for each AZ in an internet facing LB
Cannot assign EIP to internet facing load balancer
Hi @runlevel5 if you look at the section of the documentation "Specifying Elastic IPs" you'll see this can be done in terraform. The example given in the documentation is:
resource "aws_lb" "example" {
name = "example"
load_balancer_type = "network"
subnet_mapping {
subnet_id = aws_subnet.example1.id
allocation_id = aws_eip.example1.id
}
subnet_mapping {
subnet_id = aws_subnet.example2.id
allocation_id = aws_eip.example2.id
}
}
So to apply your static EIPs you use the allocation_id argument, not the private_ipv4_address argument.
Cheers!
Hi @runlevel5. The example linked above, https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#specifying-private-ip-addresses-for-an-internal-facing-load-balancer, demonstrates how to assign private IP addresses to an internal-facing LB. The example above it, https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb#specifying-elastic-ips, demonstrates using Elastic IPs.
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!