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

fix: apigatewayv2 authorizer ConflictException #37732

Merged
merged 5 commits into from
Jun 6, 2024
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
7 changes: 7 additions & 0 deletions .changelog/37732.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:bug
resource/aws_apigatewayv2_authorizer: Fix `ConflictException` errors on resource Delete
```

```release-note:enhancement
resource/aws_apigatewayv2_authorizer: Add configurable `delete` timeout
```
13 changes: 10 additions & 3 deletions internal/service/apigatewayv2/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"log"
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/apigatewayv2"
Expand Down Expand Up @@ -38,6 +39,10 @@ func resourceAuthorizer() *schema.Resource {
StateContext: resourceAuthorizerImport,
},

Timeouts: &schema.ResourceTimeout{
Delete: schema.DefaultTimeout(30 * time.Minute),
},

Schema: map[string]*schema.Schema{
"api_id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -258,9 +263,11 @@ func resourceAuthorizerDelete(ctx context.Context, d *schema.ResourceData, meta
conn := meta.(*conns.AWSClient).APIGatewayV2Client(ctx)

log.Printf("[DEBUG] Deleting API Gateway v2 Authorizer: %s", d.Id())
_, err := conn.DeleteAuthorizer(ctx, &apigatewayv2.DeleteAuthorizerInput{
ApiId: aws.String(d.Get("api_id").(string)),
AuthorizerId: aws.String(d.Id()),
_, err := tfresource.RetryWhenIsA[*awstypes.ConflictException](ctx, d.Timeout(schema.TimeoutDelete), func() (interface{}, error) {
return conn.DeleteAuthorizer(ctx, &apigatewayv2.DeleteAuthorizerInput{
ApiId: aws.String(d.Get("api_id").(string)),
AuthorizerId: aws.String(d.Id()),
})
})

if errs.IsA[*awstypes.NotFoundException](err) {
Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/apigatewayv2_authorizer.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ This resource exports the following attributes in addition to the arguments abov

* `id` - Authorizer identifier.

## Timeouts

[Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts):

- `delete` - (Default `30m`)

## Import

In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import `aws_apigatewayv2_authorizer` using the API identifier and authorizer identifier. For example:
Expand Down
Loading