diff --git a/aws/resource_aws_spot_fleet_request.go b/aws/resource_aws_spot_fleet_request.go index f5024f20d9e..1922b10cb05 100644 --- a/aws/resource_aws_spot_fleet_request.go +++ b/aws/resource_aws_spot_fleet_request.go @@ -703,22 +703,21 @@ func resourceAwsSpotFleetRequestCreate(d *schema.ResourceData, meta interface{}) // take effect immediately, resulting in an InvalidSpotFleetRequestConfig error var resp *ec2.RequestSpotFleetOutput err = resource.Retry(10*time.Minute, func() *resource.RetryError { - var err error resp, err = conn.RequestSpotFleet(spotFleetOpts) + if isAWSErr(err, "InvalidSpotFleetRequestConfig", "") { + return resource.RetryableError(fmt.Errorf("Error creating Spot fleet request, retrying: %s", err)) + } if err != nil { - if awsErr, ok := err.(awserr.Error); ok { - // IAM is eventually consistent :/ - if awsErr.Code() == "InvalidSpotFleetRequestConfig" { - return resource.RetryableError( - fmt.Errorf("Error creating Spot fleet request, retrying: %s", err)) - } - } return resource.NonRetryableError(err) } return nil }) + if isResourceTimeoutError(err) { + resp, err = conn.RequestSpotFleet(spotFleetOpts) + } + if err != nil { return fmt.Errorf("Error requesting spot fleet: %s", err) } diff --git a/aws/resource_aws_spot_instance_request.go b/aws/resource_aws_spot_instance_request.go index 5ac18f65c8a..9ef0c57e548 100644 --- a/aws/resource_aws_spot_instance_request.go +++ b/aws/resource_aws_spot_instance_request.go @@ -177,7 +177,6 @@ func resourceAwsSpotInstanceRequestCreate(d *schema.ResourceData, meta interface var resp *ec2.RequestSpotInstancesOutput err = resource.Retry(1*time.Minute, func() *resource.RetryError { - var err error resp, err = conn.RequestSpotInstances(spotOpts) // IAM instance profiles can take ~10 seconds to propagate in AWS: // http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#launch-instance-with-role-console @@ -193,6 +192,10 @@ func resourceAwsSpotInstanceRequestCreate(d *schema.ResourceData, meta interface return resource.NonRetryableError(err) }) + if isResourceTimeoutError(err) { + resp, err = conn.RequestSpotInstances(spotOpts) + } + if err != nil { return fmt.Errorf("Error requesting spot instances: %s", err) }