Skip to content

Commit

Permalink
d/aws_lb_listener: Add `mutual_authentication.advertise_trust_store_c…
Browse files Browse the repository at this point in the history
…a_names` attribute.
  • Loading branch information
ewbankkit committed Dec 20, 2024
1 parent 02ab7c3 commit 9d95691
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .changelog/#####.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
data-source/aws_lb_listener: Add `mutual_authentication.advertise_trust_store_ca_names` attribute. This fixes a regression introduced in [v5.82.0](https://github.com/hashicorp/terraform-provider-aws/blob/main/CHANGELOG.md#5820-december-19-2024) causing `setting mutual_authentication: Invalid address to set: []string{"mutual_authentication", "0", "advertise_trust_store_ca_names"}` errors
```
12 changes: 8 additions & 4 deletions internal/service/elbv2/listener_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,20 @@ func dataSourceListener() *schema.Resource {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
names.AttrMode: {
"advertise_trust_store_ca_names": {
Type: schema.TypeString,
Computed: true,
},
"trust_store_arn": {
"ignore_client_certificate_expiry": {
Type: schema.TypeBool,
Computed: true,
},
names.AttrMode: {
Type: schema.TypeString,
Computed: true,
},
"ignore_client_certificate_expiry": {
Type: schema.TypeBool,
"trust_store_arn": {
Type: schema.TypeString,
Computed: true,
},
},
Expand Down
75 changes: 53 additions & 22 deletions internal/service/elbv2/listener_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestAccELBV2ListenerDataSource_basic(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_lb_listener.test"
dataSourceName := "data.aws_lb_listener.test"
dataSource1Name := "data.aws_lb_listener.test"
dataSourceName2 := "data.aws_alb_listener.from_lb_and_port"

resource.ParallelTest(t, resource.TestCase{
Expand All @@ -28,28 +28,51 @@ func TestAccELBV2ListenerDataSource_basic(t *testing.T) {
{
Config: testAccListenerDataSourceConfig_basic(rName),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "alpn_policy", resourceName, "alpn_policy"),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrARN, resourceName, names.AttrARN),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrCertificateARN, resourceName, names.AttrCertificateARN),
resource.TestCheckResourceAttrPair(dataSourceName, "default_action.#", resourceName, "default_action.#"),
resource.TestCheckResourceAttrPair(dataSourceName, "default_action.0.target_group_arn", resourceName, "default_action.0.target_group_arn"),
resource.TestCheckResourceAttrPair(dataSourceName, "load_balancer_arn", resourceName, "load_balancer_arn"),
resource.TestCheckResourceAttrPair(dataSource1Name, "alpn_policy", resourceName, "alpn_policy"),
resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrARN, resourceName, names.AttrARN),
resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrCertificateARN, resourceName, names.AttrCertificateARN),
resource.TestCheckResourceAttrPair(dataSource1Name, "default_action.#", resourceName, "default_action.#"),
resource.TestCheckResourceAttrPair(dataSource1Name, "default_action.0.target_group_arn", resourceName, "default_action.0.target_group_arn"),
resource.TestCheckResourceAttrPair(dataSource1Name, "load_balancer_arn", resourceName, "load_balancer_arn"),
resource.TestCheckResourceAttrPair(dataSource1Name, "mutual_authentication.#", resourceName, "mutual_authentication.#"),
resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrPort, resourceName, names.AttrPort),
resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrProtocol, resourceName, names.AttrProtocol),
resource.TestCheckResourceAttrPair(dataSource1Name, "ssl_policy", resourceName, "ssl_policy"),
resource.TestCheckResourceAttrPair(dataSource1Name, acctest.CtTagsPercent, resourceName, acctest.CtTagsPercent),
resource.TestCheckResourceAttrPair(dataSourceName2, "alpn_policy", dataSource1Name, "alpn_policy"),
resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrARN, dataSource1Name, names.AttrARN),
resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrCertificateARN, dataSource1Name, names.AttrCertificateARN),
resource.TestCheckResourceAttrPair(dataSourceName2, "default_action.#", dataSource1Name, "default_action.#"),
resource.TestCheckResourceAttrPair(dataSourceName2, "default_action.0.target_group_arn", dataSource1Name, "default_action.0.target_group_arn"),
resource.TestCheckResourceAttrPair(dataSourceName2, "load_balancer_arn", dataSource1Name, "load_balancer_arn"),
resource.TestCheckResourceAttrPair(dataSourceName2, "mutual_authentication.#", dataSource1Name, "mutual_authentication.#"),
resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrPort, dataSource1Name, names.AttrPort),
resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrProtocol, dataSource1Name, names.AttrProtocol),
resource.TestCheckResourceAttrPair(dataSourceName2, "ssl_policy", dataSource1Name, "ssl_policy"),
resource.TestCheckResourceAttrPair(dataSourceName2, acctest.CtTagsPercent, dataSource1Name, acctest.CtTagsPercent),
),
},
},
})
}

func TestAccELBV2ListenerDataSource_mutualAuthentication(t *testing.T) {
ctx := acctest.Context(t)
key := acctest.TLSRSAPrivateKeyPEM(t, 2048)
resourceName := "aws_lb_listener.test"
dataSourceName := "data.aws_lb_listener.test"
certificate := acctest.TLSRSAX509SelfSignedCertificatePEM(t, key, "example.com")
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccListenerDataSourceConfig_mutualAuthentication(rName, key, certificate),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "mutual_authentication.#", resourceName, "mutual_authentication.#"),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrPort, resourceName, names.AttrPort),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrProtocol, resourceName, names.AttrProtocol),
resource.TestCheckResourceAttrPair(dataSourceName, "ssl_policy", resourceName, "ssl_policy"),
resource.TestCheckResourceAttrPair(dataSourceName, acctest.CtTagsPercent, resourceName, acctest.CtTagsPercent),
resource.TestCheckResourceAttrPair(dataSourceName2, "alpn_policy", dataSourceName, "alpn_policy"),
resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrARN, dataSourceName, names.AttrARN),
resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrCertificateARN, dataSourceName, names.AttrCertificateARN),
resource.TestCheckResourceAttrPair(dataSourceName2, "default_action.#", dataSourceName, "default_action.#"),
resource.TestCheckResourceAttrPair(dataSourceName2, "default_action.0.target_group_arn", dataSourceName, "default_action.0.target_group_arn"),
resource.TestCheckResourceAttrPair(dataSourceName2, "load_balancer_arn", dataSourceName, "load_balancer_arn"),
resource.TestCheckResourceAttrPair(dataSourceName2, "mutual_authentication.#", dataSourceName, "mutual_authentication.#"),
resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrPort, dataSourceName, names.AttrPort),
resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrProtocol, dataSourceName, names.AttrProtocol),
resource.TestCheckResourceAttrPair(dataSourceName2, "ssl_policy", dataSourceName, "ssl_policy"),
resource.TestCheckResourceAttrPair(dataSourceName2, acctest.CtTagsPercent, dataSourceName, acctest.CtTagsPercent),
),
},
},
Expand Down Expand Up @@ -111,3 +134,11 @@ data "aws_alb_listener" "from_lb_and_port" {
}
`, rName))
}

func testAccListenerDataSourceConfig_mutualAuthentication(rName, key, certificate string) string {
return acctest.ConfigCompose(testAccListenerConfig_mutualAuthentication(rName, key, certificate), `
data "aws_lb_listener" "test" {
arn = aws_lb_listener.test.arn
}
`)
}
6 changes: 3 additions & 3 deletions internal/service/elbv2/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3308,7 +3308,7 @@ resource "aws_internet_gateway" "test" {
`, rName, acctest.TLSPEMEscapeNewlines(certificate), acctest.TLSPEMEscapeNewlines(key)))
}

func testAccListenerConfig_mutualAuthentication(rName string, key, certificate string) string {
func testAccListenerConfig_mutualAuthentication(rName, key, certificate string) string {
return acctest.ConfigCompose(
testAccListenerConfig_base(rName),
testAccTrustStoreConfig_baseS3BucketCA(rName),
Expand Down Expand Up @@ -3381,7 +3381,7 @@ resource "aws_iam_server_certificate" "test" {
`, rName, acctest.TLSPEMEscapeNewlines(certificate), acctest.TLSPEMEscapeNewlines(key)))
}

func testAccListenerConfig_mutualAuthenticationAdvertiseCASubject(rName string, key, certificate string) string {
func testAccListenerConfig_mutualAuthenticationAdvertiseCASubject(rName, key, certificate string) string {
return acctest.ConfigCompose(
testAccListenerConfig_base(rName),
testAccTrustStoreConfig_baseS3BucketCA(rName),
Expand Down Expand Up @@ -3455,7 +3455,7 @@ resource "aws_iam_server_certificate" "test" {
`, rName, acctest.TLSPEMEscapeNewlines(certificate), acctest.TLSPEMEscapeNewlines(key)))
}

func testAccListenerConfig_mutualAuthenticationPassthrough(rName string, key, certificate string) string {
func testAccListenerConfig_mutualAuthenticationPassthrough(rName, key, certificate string) string {
return acctest.ConfigCompose(
testAccListenerConfig_base(rName),
fmt.Sprintf(`
Expand Down

0 comments on commit 9d95691

Please sign in to comment.