Skip to content

Commit

Permalink
resource/aws_gamelift_fleet: Check resource.TimeoutError on creation (#…
Browse files Browse the repository at this point in the history
…15526)

Reference: #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)
```
  • Loading branch information
bflad authored Oct 7, 2020
1 parent 4dadb10 commit 687adc6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions aws/resource_aws_gamelift_fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 687adc6

Please sign in to comment.