Skip to content

Commit 2178e7b

Browse files
authored
Merge pull request #44485 from tabito-hara/b-aws_lb-fix_panic_due_to_missing_attribute
[bugfix] d/aws_lb: Fix panic caused by missing `secondary_ips_auto_assigned_per_subnet` in schema definition
2 parents a38489e + b88e360 commit 2178e7b

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

.changelog/44485.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
data-source/aws_lb: Fix `Invalid address to set: []string{"secondary_ips_auto_assigned_per_subnet"}` errors
3+
```

internal/service/elbv2/load_balancer_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ func dataSourceLoadBalancer() *schema.Resource {
175175
Type: schema.TypeBool,
176176
Computed: true,
177177
},
178+
"secondary_ips_auto_assigned_per_subnet": {
179+
Type: schema.TypeInt,
180+
Computed: true,
181+
},
178182
names.AttrSecurityGroups: {
179183
Type: schema.TypeSet,
180184
Elem: &schema.Schema{Type: schema.TypeString},

internal/service/elbv2/load_balancer_data_source_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,28 @@ func TestAccELBV2LoadBalancerDataSource_backwardsCompatibility(t *testing.T) {
216216
})
217217
}
218218

219+
func TestAccELBV2LoadBalancerDataSource_nlbSecondaryIPAddresses(t *testing.T) {
220+
ctx := acctest.Context(t)
221+
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
222+
dataSourceName := "data.aws_lb.nlb_test_with_arn"
223+
resourceName := "aws_lb.test"
224+
225+
resource.ParallelTest(t, resource.TestCase{
226+
PreCheck: func() { acctest.PreCheck(ctx, t) },
227+
ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID),
228+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
229+
Steps: []resource.TestStep{
230+
{
231+
Config: testAccLoadBalancerDataSourceConfig_nlbSecondaryIPAddresses(rName, 3, 3),
232+
Check: resource.ComposeAggregateTestCheckFunc(
233+
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, resourceName, names.AttrName),
234+
resource.TestCheckResourceAttrPair(dataSourceName, "secondary_ips_auto_assigned_per_subnet", resourceName, "secondary_ips_auto_assigned_per_subnet"),
235+
),
236+
},
237+
},
238+
})
239+
}
240+
219241
func testAccLoadBalancerDataSourceConfig_basic(rName string) string {
220242
return acctest.ConfigCompose(acctest.ConfigVPCWithSubnets(rName, 2), fmt.Sprintf(`
221243
resource "aws_lb" "test" {
@@ -397,3 +419,11 @@ data "aws_alb" "alb_test_with_tags" {
397419
}
398420
`, rName))
399421
}
422+
423+
func testAccLoadBalancerDataSourceConfig_nlbSecondaryIPAddresses(rName string, subnetCount, addressCount int) string {
424+
return acctest.ConfigCompose(testAccLoadBalancerConfig_nlbSecondaryIPAddresses(rName, subnetCount, addressCount), `
425+
data "aws_lb" "nlb_test_with_arn" {
426+
arn = aws_lb.test.arn
427+
}
428+
`)
429+
}

0 commit comments

Comments
 (0)