The aws_lb examples show how to create a NLB with a set of static elastic IP addresses - which works fine, however as they are EIP’s they are by definition public addresses. The AWS console permits creating an internal only NLB with per-defined static internal addresses, however I’ve not discovered how this would be possible - either in the doco or (in desperation) reading through the providers code.
Existing ALB doco
Does anyone have an example of doing so, or is this something the provider / sdk doesn’t allow?
Thanks
Antony.
What happens if you mark it as internal = true
and just give it a list of internal subnets
to attach to?
That does work, however does not allow you to specify the IP addresses - which is the goal of creating the nlb.
I see. Hmmm…
Looking at the SDK , it seems you should be able to do subnet mappings using either EIPs or internal ip addresses.
The Terraform docs only mention EIPs but have you tried to specify internal IPs?
The Terraform docs only mention EIPs but have you tried to specify internal IPs?
I have the same issue: want attach static internal IP to NLB.
According to Terraform doc you have to specify allocation_id of EIP resource. So, you will not able to attach internal IP in this manner because you doesn’t have allocation_id for internal IP.
That’s what I found:
hashicorp:master
←
opened 02:37AM - 22 Dec 19 UTC
Please let me know if there's anything else I should update, this is my first PR… to `terraform-provider-aws`. I've tested this feature by creating an `aws_lb` like the example below. I've verified that the subnet mapping in the aws console shows the private ipv4 address.
### steps to test;
```hcl
provider "aws" {
region = "us-east-1"
profile = "default"
}
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/20"
tags = {
Name = "test-vpc"
}
}
resource "aws_subnet" "test" {
vpc_id = "${aws_vpc.test.id}"
cidr_block = "10.0.1.0/24"
tags = {
Name = "test-subnet"
}
}
resource "aws_lb" "test" {
name = "test-lb-tf"
internal = true
load_balancer_type = "network"
subnet_mapping {
subnet_id = aws_subnet.test.id
private_ipv4_address = "10.0.1.15"
}
}
```
### Community Note
* Please vote on this pull request by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original pull request comment 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 pull request followers and do not help prioritize the request
fixes https://github.com/terraform-providers/terraform-provider-aws/issues/11403
fixes https://github.com/terraform-providers/terraform-provider-aws/issues/11044
Release note for [CHANGELOG](https://github.com/terraform-providers/terraform-provider-aws/blob/master/CHANGELOG.md):
<!--
If change is not user facing, just write "NONE" in the release-note block below.
-->
```release-note
add support for private ipv4 address in subnet mappings of resource aws_lb
```
Output from acceptance testing:
<!--
Replace TestAccXXX with a pattern that matches the tests affected by this PR.
For more information on the `-run` flag, see the `go test` documentation at https://tip.golang.org/cmd/go/#hdr-Testing_flags.
-->
```
$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSLB_NLB_privateipv4address'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSLB_NLB_privateipv4address -timeout 120m
=== RUN TestAccAWSLB_NLB_privateipv4address
=== PAUSE TestAccAWSLB_NLB_privateipv4address
=== CONT TestAccAWSLB_NLB_privateipv4address
--- PASS: TestAccAWSLB_NLB_privateipv4address (228.60s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 228.635s
```
Current status is: awaiting for maintainer review