Terraform-provider-aws: [NLB] Cannot assign static IP (EIP) to subnet mapping for internet facing type of NLB

Created on 20 Sep 2020  ·  3Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Context

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.

Expected Behavior

EIP can be assigned for each AZ in an internet facing LB

Actual Behavior

Cannot assign EIP to internet facing load balancer

question

All 3 comments

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!

Was this page helpful?
0 / 5 - 0 ratings