-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for private ipv4 addresses in subnet mapping of ELB V2 #11404
Changes from all commits
a1c1148
59620e6
fcd1ab8
f3d6bbe
da94db6
2774aa2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,6 +191,40 @@ func TestAccAWSLB_networkLoadbalancerEIP(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAWSLB_NLB_privateipv4address(t *testing.T) { | ||
var conf elbv2.LoadBalancer | ||
lbName := fmt.Sprintf("testaccawslb-pipv4a-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) | ||
resourceName := "aws_lb.lb_test" | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
IDRefreshName: resourceName, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSLBDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAWSLBConfig_networkLoadBalancerPrivateIPV4Address(lbName), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
testAccCheckAWSLBExists(resourceName, &conf), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. most of these check are irrelevant to the specific case, lets leave only the relevant check
|
||
resource.TestCheckResourceAttr(resourceName, "access_logs.#", "1"), | ||
resource.TestCheckResourceAttr(resourceName, "access_logs.0.enabled", "false"), | ||
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "elasticloadbalancing", regexp.MustCompile(fmt.Sprintf("loadbalancer/net/%s/.+", lbName))), | ||
resource.TestCheckResourceAttrSet(resourceName, "dns_name"), | ||
resource.TestCheckResourceAttr(resourceName, "enable_deletion_protection", "false"), | ||
resource.TestCheckResourceAttr(resourceName, "internal", "true"), | ||
resource.TestCheckResourceAttr(resourceName, "ip_address_type", "ipv4"), | ||
resource.TestCheckResourceAttr(resourceName, "load_balancer_type", "network"), | ||
resource.TestCheckResourceAttr(resourceName, "name", lbName), | ||
resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), | ||
resource.TestCheckResourceAttr(resourceName, "tags.Name", "TestAccAWSALB_privateipv4address"), | ||
resource.TestCheckResourceAttrSet(resourceName, "zone_id"), | ||
resource.TestCheckResourceAttr(resourceName, "subnet_mapping.#", "1"), | ||
), | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add import step:
|
||
}, | ||
}) | ||
} | ||
|
||
func TestAccAWSLBBackwardsCompatibility(t *testing.T) { | ||
var conf elbv2.LoadBalancer | ||
lbName := fmt.Sprintf("testaccawslb-basic-%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)) | ||
|
@@ -1770,6 +1804,46 @@ resource "aws_eip" "lb" { | |
`, lbName) | ||
} | ||
|
||
func testAccAWSLBConfig_networkLoadBalancerPrivateIPV4Address(lbName string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_lb" "lb_test" { | ||
name = "%s" | ||
internal = true | ||
load_balancer_type = "network" | ||
|
||
enable_deletion_protection = false | ||
|
||
subnet_mapping { | ||
subnet_id = "${aws_subnet.alb_test.id}" | ||
private_ipv4_address = "10.10.0.15" | ||
} | ||
|
||
tags = { | ||
Name = "TestAccAWSALB_privateipv4address" | ||
} | ||
} | ||
|
||
resource "aws_vpc" "alb_test" { | ||
cidr_block = "10.10.0.0/16" | ||
|
||
tags = { | ||
Name = "TestAccAWSALB_privateipv4address" | ||
} | ||
} | ||
|
||
resource "aws_subnet" "alb_test" { | ||
vpc_id = "${aws_vpc.alb_test.id}" | ||
cidr_block = "10.10.0.0/21" | ||
map_public_ip_on_launch = true | ||
availability_zone = "us-west-2a" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to make test region agnostic and to avoid environment specific failures, can please add the following to the test config:
and change the hardcoded az to |
||
|
||
tags = { | ||
Name = "TestAccAWSALB_privateipv4address" | ||
} | ||
} | ||
`, lbName) | ||
} | ||
|
||
func testAccAWSLBConfigBackwardsCompatibility(lbName string) string { | ||
return fmt.Sprintf(` | ||
resource "aws_alb" "lb_test" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add validation here
ValidateFunc: validation.IsIPv4Address,