From dcab4273ed51b18c3299fcc3e5a42048f5864d94 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 6 Oct 2020 14:42:57 -0400 Subject: [PATCH] resource/aws_gamelift_fleet: Check resource.TimeoutError on creation Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/12985 Output from acceptance testing: ``` --- PASS: TestAccAWSGameliftFleet_tags (1703.23s) --- PASS: TestAccAWSGameliftFleet_basic (1707.75s) --- PASS: TestAccAWSGameliftFleet_disappears (1725.93s) --- PASS: TestAccAWSGameliftFleet_allFields (1763.86s) ``` --- aws/resource_aws_gamelift_fleet.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_gamelift_fleet.go b/aws/resource_aws_gamelift_fleet.go index d728d162bd2..ff06c9a2042 100644 --- a/aws/resource_aws_gamelift_fleet.go +++ b/aws/resource_aws_gamelift_fleet.go @@ -8,10 +8,13 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/gamelift" + "github.com/hashicorp/aws-sdk-go-base/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" + iamwaiter "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/iam/waiter" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/tfresource" ) func resourceAwsGameliftFleet() *schema.Resource { @@ -232,19 +235,27 @@ func resourceAwsGameliftFleetCreate(d *schema.ResourceData, meta interface{}) er log.Printf("[INFO] Creating Gamelift Fleet: %s", input) var out *gamelift.CreateFleetOutput - err := resource.Retry(3*time.Minute, func() *resource.RetryError { + err := resource.Retry(iamwaiter.PropagationTimeout, func() *resource.RetryError { var err error out, err = conn.CreateFleet(&input) - if isAWSErr(err, gamelift.ErrCodeInvalidRequestException, "GameLift is not authorized to perform") { + + if tfawserr.ErrMessageContains(err, gamelift.ErrCodeInvalidRequestException, "GameLift is not authorized to perform") { return resource.RetryableError(err) } + if err != nil { return resource.NonRetryableError(err) } + return nil }) + + if tfresource.TimedOut(err) { + out, err = conn.CreateFleet(&input) + } + if err != nil { - return err + return fmt.Errorf("error creating GameLift Fleet (%s): %w", d.Get("name").(string), err) } d.SetId(*out.FleetAttributes.FleetId)