Skip to content

Commit

Permalink
Merge pull request #40708 from A-Shevchenko/b-wrong-arg-getdomainapi-…
Browse files Browse the repository at this point in the history
…call-40699

aws_api_gateway_domain_name - fixed issue when policy is added to private domain name after initial creation
  • Loading branch information
ewbankkit authored Dec 29, 2024
2 parents 017df23 + d6432c0 commit 48d2e08
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/40708.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_api_gateway_domain_name: Fixed error when adding policy to existing private domain name
```
2 changes: 1 addition & 1 deletion internal/service/apigateway/domain_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
38 changes: 38 additions & 0 deletions internal/service/apigateway/domain_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 48d2e08

Please sign in to comment.