From 1781e802841c23b4b225009b1ec5737c568ff26a Mon Sep 17 00:00:00 2001 From: Ryn Daniels Date: Thu, 25 Jul 2019 15:12:11 +0200 Subject: [PATCH] Final retries for timeouts on SFN objects --- aws/resource_aws_sfn_activity.go | 16 ++++++++++++---- aws/resource_aws_sfn_state_machine.go | 20 +++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/aws/resource_aws_sfn_activity.go b/aws/resource_aws_sfn_activity.go index 6a88e5348e6..f1d95dd0083 100644 --- a/aws/resource_aws_sfn_activity.go +++ b/aws/resource_aws_sfn_activity.go @@ -143,10 +143,11 @@ func resourceAwsSfnActivityDelete(d *schema.ResourceData, meta interface{}) erro conn := meta.(*AWSClient).sfnconn log.Printf("[DEBUG] Deleting Step Functions Activity: %s", d.Id()) - return resource.Retry(5*time.Minute, func() *resource.RetryError { - _, err := conn.DeleteActivity(&sfn.DeleteActivityInput{ - ActivityArn: aws.String(d.Id()), - }) + input := &sfn.DeleteActivityInput{ + ActivityArn: aws.String(d.Id()), + } + err := resource.Retry(5*time.Minute, func() *resource.RetryError { + _, err := conn.DeleteActivity(input) if err == nil { return nil @@ -154,4 +155,11 @@ func resourceAwsSfnActivityDelete(d *schema.ResourceData, meta interface{}) erro return resource.NonRetryableError(err) }) + if isResourceTimeoutError(err) { + _, err = conn.DeleteActivity(input) + } + if err != nil { + return fmt.Errorf("Error deleting SFN Activity: %s", err) + } + return nil } diff --git a/aws/resource_aws_sfn_state_machine.go b/aws/resource_aws_sfn_state_machine.go index b23c012857e..cf0844c899b 100644 --- a/aws/resource_aws_sfn_state_machine.go +++ b/aws/resource_aws_sfn_state_machine.go @@ -87,6 +87,9 @@ func resourceAwsSfnStateMachineCreate(d *schema.ResourceData, meta interface{}) return nil }) + if isResourceTimeoutError(err) { + activity, err = conn.CreateStateMachine(params) + } if err != nil { return fmt.Errorf("Error creating Step Function State Machine: %s", err) @@ -202,7 +205,6 @@ func resourceAwsSfnStateMachineUpdate(d *schema.ResourceData, meta interface{}) } } } - return resourceAwsSfnStateMachineRead(d, meta) } @@ -210,10 +212,11 @@ func resourceAwsSfnStateMachineDelete(d *schema.ResourceData, meta interface{}) conn := meta.(*AWSClient).sfnconn log.Printf("[DEBUG] Deleting Step Function State Machine: %s", d.Id()) - return resource.Retry(5*time.Minute, func() *resource.RetryError { - _, err := conn.DeleteStateMachine(&sfn.DeleteStateMachineInput{ - StateMachineArn: aws.String(d.Id()), - }) + input := &sfn.DeleteStateMachineInput{ + StateMachineArn: aws.String(d.Id()), + } + err := resource.Retry(5*time.Minute, func() *resource.RetryError { + _, err := conn.DeleteStateMachine(input) if err == nil { return nil @@ -221,4 +224,11 @@ func resourceAwsSfnStateMachineDelete(d *schema.ResourceData, meta interface{}) return resource.NonRetryableError(err) }) + if isResourceTimeoutError(err) { + _, err = conn.DeleteStateMachine(input) + } + if err != nil { + return fmt.Errorf("Error deleting SFN state machine: %s", err) + } + return nil }