Skip to content
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

aws_api_gateway_domain_name - fixed issue when policy is added to private domain name after initial creation #40708

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading