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

Add 'timeout' attribute to Glue Trigger create, update and delete #35542

Merged
merged 6 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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/35542.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_glue_trigger: Add `timeouts` configuration
```
6 changes: 3 additions & 3 deletions internal/service/glue/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func resourceTriggerCreate(ctx context.Context, d *schema.ResourceData, meta int
d.SetId(name)

log.Printf("[DEBUG] Waiting for Glue Trigger (%s) to create", d.Id())
if _, err := waitTriggerCreated(ctx, conn, d.Id()); err != nil {
if _, err := waitTriggerCreated(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil {
if tfawserr.ErrCodeEquals(err, glue.ErrCodeEntityNotFoundException) {
return diags
}
Expand Down Expand Up @@ -407,7 +407,7 @@ func resourceTriggerUpdate(ctx context.Context, d *schema.ResourceData, meta int
return sdkdiag.AppendErrorf(diags, "updating Glue Trigger (%s): %s", d.Id(), err)
}

if _, err := waitTriggerCreated(ctx, conn, d.Id()); err != nil {
if _, err := waitTriggerCreated(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil {
return sdkdiag.AppendErrorf(diags, "waiting for Glue Trigger (%s) to be Update: %s", d.Id(), err)
}
}
Expand Down Expand Up @@ -453,7 +453,7 @@ func resourceTriggerDelete(ctx context.Context, d *schema.ResourceData, meta int
}

log.Printf("[DEBUG] Waiting for Glue Trigger (%s) to delete", d.Id())
if _, err := waitTriggerDeleted(ctx, conn, d.Id()); err != nil {
if _, err := waitTriggerDeleted(ctx, conn, d.Id(), d.Timeout(schema.TimeoutDelete)); err != nil {
if tfawserr.ErrCodeEquals(err, glue.ErrCodeEntityNotFoundException) {
return diags
}
Expand Down
10 changes: 4 additions & 6 deletions internal/service/glue/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const (
schemaAvailableTimeout = 2 * time.Minute
schemaDeleteTimeout = 2 * time.Minute
schemaVersionAvailableTimeout = 2 * time.Minute
triggerCreateTimeout = 5 * time.Minute
triggerDeleteTimeout = 5 * time.Minute
)

// waitMLTransformDeleted waits for an MLTransform to return Deleted
Expand Down Expand Up @@ -116,7 +114,7 @@ func waitSchemaVersionAvailable(ctx context.Context, conn *glue.Glue, registryID
}

// waitTriggerCreated waits for a Trigger to return Created
func waitTriggerCreated(ctx context.Context, conn *glue.Glue, triggerName string) (*glue.GetTriggerOutput, error) { //nolint:unparam
func waitTriggerCreated(ctx context.Context, conn *glue.Glue, triggerName string, timeout time.Duration) (*glue.GetTriggerOutput, error) { //nolint:unparam
stateConf := &retry.StateChangeConf{
Pending: []string{
glue.TriggerStateActivating,
Expand All @@ -128,7 +126,7 @@ func waitTriggerCreated(ctx context.Context, conn *glue.Glue, triggerName string
glue.TriggerStateCreated,
},
Refresh: statusTrigger(ctx, conn, triggerName),
Timeout: triggerCreateTimeout,
Timeout: timeout,
}

outputRaw, err := stateConf.WaitForStateContext(ctx)
Expand All @@ -141,12 +139,12 @@ func waitTriggerCreated(ctx context.Context, conn *glue.Glue, triggerName string
}

// waitTriggerDeleted waits for a Trigger to return Deleted
func waitTriggerDeleted(ctx context.Context, conn *glue.Glue, triggerName string) (*glue.GetTriggerOutput, error) {
func waitTriggerDeleted(ctx context.Context, conn *glue.Glue, triggerName string, timeout time.Duration) (*glue.GetTriggerOutput, error) {
stateConf := &retry.StateChangeConf{
Pending: []string{glue.TriggerStateDeleting},
Target: []string{},
Refresh: statusTrigger(ctx, conn, triggerName),
Timeout: triggerDeleteTimeout,
Timeout: timeout,
}

outputRaw, err := stateConf.WaitForStateContext(ctx)
Expand Down
Loading