From 84171c01c316b41c7e633c441eb5520e50943135 Mon Sep 17 00:00:00 2001 From: Andrii Shevchenko Date: Fri, 27 Dec 2024 16:14:19 +0100 Subject: [PATCH 1/3] fixed wrong value passed to GetDomainName during resource update --- internal/service/apigateway/domain_name.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/apigateway/domain_name.go b/internal/service/apigateway/domain_name.go index 780f0a3c8bd..4a6181ac20b 100644 --- a/internal/service/apigateway/domain_name.go +++ b/internal/service/apigateway/domain_name.go @@ -438,7 +438,7 @@ func resourceDomainNameUpdate(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "updating API Gateway Domain Name (%s): %s", d.Id(), err) } - if _, err := waitDomainNameUpdated(ctx, conn, d.Id(), domainNameID); err != nil { + if _, err := waitDomainNameUpdated(ctx, conn, domainName, domainNameID); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for API Gateway Domain Name (%s) update: %s", d.Id(), err) } } From 27934f9e318071f4c1333df386284b0a45240406 Mon Sep 17 00:00:00 2001 From: Andrii Shevchenko Date: Fri, 27 Dec 2024 16:14:20 +0100 Subject: [PATCH 2/3] added test to catch issue when policy is added after initial domain name creation --- .../service/apigateway/domain_name_test.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/internal/service/apigateway/domain_name_test.go b/internal/service/apigateway/domain_name_test.go index 0cb3f47b4c6..a6ca7c9f423 100644 --- a/internal/service/apigateway/domain_name_test.go +++ b/internal/service/apigateway/domain_name_test.go @@ -291,6 +291,44 @@ func TestAccAPIGatewayDomainName_privatePolicy(t *testing.T) { }) } +func TestAccAPIGatewayDomainName_privatePolicy_added(t *testing.T) { + ctx := acctest.Context(t) + var domainName apigateway.GetDomainNameOutput + resourceName := "aws_api_gateway_domain_name.test" + rName := acctest.RandomSubdomain() + key := acctest.TLSRSAPrivateKeyPEM(t, 2048) + certificate := acctest.TLSRSAX509SelfSignedCertificatePEM(t, key, rName) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, names.APIGatewayServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckDomainNameDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccDomainNameConfig_private(rName, key, certificate), + Check: resource.ComposeTestCheckFunc( + testAccCheckDomainNameExists(ctx, resourceName, &domainName), + resource.TestCheckResourceAttrSet(resourceName, "domain_name_id"), + ), + }, + { + Config: testAccDomainNameConfig_privatePolicy(rName, key, certificate), + Check: resource.ComposeTestCheckFunc( + testAccCheckDomainNameExists(ctx, resourceName, &domainName), + resource.TestCheckResourceAttrSet(resourceName, "domain_name_id"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrPolicy), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAPIGatewayDomainName_disappears(t *testing.T) { ctx := acctest.Context(t) var domainName apigateway.GetDomainNameOutput From d6432c0dc017cdb8529e34c4ebd88a396775dff9 Mon Sep 17 00:00:00 2001 From: Andrii Shevchenko Date: Fri, 27 Dec 2024 17:38:01 +0100 Subject: [PATCH 3/3] added changelog entry --- .changelog/40708.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/40708.txt diff --git a/.changelog/40708.txt b/.changelog/40708.txt new file mode 100644 index 00000000000..76a0cef6b90 --- /dev/null +++ b/.changelog/40708.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_api_gateway_domain_name: Fixed error when adding policy to existing private domain name +``` \ No newline at end of file