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

New resource aws_glue_dev_endpoint #7895

Merged
23 changes: 23 additions & 0 deletions aws/internal/service/glue/waiter/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package waiter
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/glue"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

Expand Down Expand Up @@ -52,3 +53,25 @@ func TriggerStatus(conn *glue.Glue, triggerName string) resource.StateRefreshFun
return output, aws.StringValue(output.Trigger.State), nil
}
}

func GlueDevEndpointStatus(conn *glue.Glue, name string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
getDevEndpointInput := &glue.GetDevEndpointInput{
EndpointName: aws.String(name),
}
endpoint, err := conn.GetDevEndpoint(getDevEndpointInput)
if err != nil {
if tfawserr.ErrCodeEquals(err, glue.ErrCodeEntityNotFoundException) {
return nil, "", nil
}

return nil, "", err
}

if endpoint == nil {
return nil, "", nil
}

return endpoint, aws.StringValue(endpoint.DevEndpoint.Status), nil
}
}
38 changes: 38 additions & 0 deletions aws/internal/service/glue/waiter/waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,41 @@ func TriggerDeleted(conn *glue.Glue, triggerName string) (*glue.GetTriggerOutput

return nil, err
}

// GlueDevEndpointCreated waits for a Glue Dev Endpoint to become available.
func GlueDevEndpointCreated(conn *glue.Glue, devEndpointId string) (*glue.GetDevEndpointOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{
"PROVISIONING",
},
Target: []string{"READY"},
Refresh: GlueDevEndpointStatus(conn, devEndpointId),
Timeout: 15 * time.Minute,
}

outputRaw, err := stateConf.WaitForState()

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

return nil, err
}

// GlueDevEndpointDeleted waits for a Glue Dev Endpoint to become terminated.
func GlueDevEndpointDeleted(conn *glue.Glue, devEndpointId string) (*glue.GetDevEndpointOutput, error) {
stateConf := &resource.StateChangeConf{
Pending: []string{"TERMINATING"},
Target: []string{},
Refresh: GlueDevEndpointStatus(conn, devEndpointId),
Timeout: 15 * time.Minute,
}

outputRaw, err := stateConf.WaitForState()

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

return nil, err
}
1 change: 1 addition & 0 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ func Provider() *schema.Provider {
"aws_glue_catalog_table": resourceAwsGlueCatalogTable(),
"aws_glue_classifier": resourceAwsGlueClassifier(),
"aws_glue_connection": resourceAwsGlueConnection(),
"aws_glue_dev_endpoint": resourceAwsGlueDevEndpoint(),
"aws_glue_crawler": resourceAwsGlueCrawler(),
"aws_glue_data_catalog_encryption_settings": resourceAwsGlueDataCatalogEncryptionSettings(),
"aws_glue_job": resourceAwsGlueJob(),
Expand Down
Loading