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

r/glue_trigger - add support for security_configuration and notification_property for actions + refactor tests and waiters #15793

Merged
merged 16 commits into from
Nov 4, 2020
24 changes: 23 additions & 1 deletion aws/internal/service/glue/waiter/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (

const (
MLTransformStatusUnknown = "Unknown"
TriggerStatusUnknown = "Unknown"
)

// MLTransformStatus fetches the Operation and its Status
// MLTransformStatus fetches the MLTransform and its Status
func MLTransformStatus(conn *glue.Glue, transformId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &glue.GetMLTransformInput{
Expand All @@ -30,3 +31,24 @@ func MLTransformStatus(conn *glue.Glue, transformId string) resource.StateRefres
return output, aws.StringValue(output.Status), nil
}
}

// TriggerStatus fetches the Trigger and its Status
func TriggerStatus(conn *glue.Glue, triggerName string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
input := &glue.GetTriggerInput{
Name: aws.String(triggerName),
}

output, err := conn.GetTrigger(input)

if err != nil {
return nil, TriggerStatusUnknown, err
}

if output == nil {
return output, TriggerStatusUnknown, nil
}

return output, aws.StringValue(output.Trigger.State), nil
}
}
50 changes: 47 additions & 3 deletions aws/internal/service/glue/waiter/waiter.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package waiter

import (
"github.com/aws/aws-sdk-go/service/glue"
"time"

"github.com/aws/aws-sdk-go/service/glue"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

const (
// Maximum amount of time to wait for an Operation to return Success
// Maximum amount of time to wait for an Operation to return Deleted
MLTransformDeleteTimeout = 2 * time.Minute
TriggerCreateTimeout = 2 * time.Minute
TriggerDeleteTimeout = 2 * time.Minute
)

// MLTransformDeleted waits for an Operation to return Success
// MLTransformDeleted waits for an MLTransform to return Deleted
func MLTransformDeleted(conn *glue.Glue, transformId string) (*glue.GetMLTransformOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{glue.TransformStatusTypeNotReady, glue.TransformStatusTypeReady, glue.TransformStatusTypeDeleting},
Expand All @@ -29,3 +31,45 @@ func MLTransformDeleted(conn *glue.Glue, transformId string) (*glue.GetMLTransfo

return nil, err
}

// TriggerCreated waits for a Trigger to return Created
func TriggerCreated(conn *glue.Glue, triggerName string) (*glue.GetTriggerOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{
glue.TriggerStateActivating,
glue.TriggerStateCreating,
},
Target: []string{
glue.TriggerStateActivated,
glue.TriggerStateCreated,
},
Refresh: TriggerStatus(conn, triggerName),
Timeout: TriggerCreateTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*glue.GetTriggerOutput); ok {
return output, err
}

return nil, err
}

// TriggerDeleted waits for a Trigger to return Deleted
func TriggerDeleted(conn *glue.Glue, triggerName string) (*glue.GetTriggerOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{glue.TriggerStateDeleting},
Target: []string{},
Refresh: TriggerStatus(conn, triggerName),
Timeout: TriggerDeleteTimeout,
}

outputRaw, err := stateConf.WaitForState()

if output, ok := outputRaw.(*glue.GetTriggerOutput); ok {
return output, err
}

return nil, err
}
Loading