Skip to content

Commit

Permalink
resource/aws_appautoscaling_policy: Inside retry functions use isAWSE…
Browse files Browse the repository at this point in the history
…rr helper function and return NonRetryableError for API errors outside rate limiting
  • Loading branch information
bflad committed May 21, 2018
1 parent ce42655 commit 83b6b39
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions aws/resource_aws_appautoscaling_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/applicationautoscaling"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
Expand Down Expand Up @@ -292,11 +291,10 @@ func resourceAwsAppautoscalingPolicyRead(d *schema.ResourceData, meta interface{
var err error
p, err = getAwsAppautoscalingPolicy(d, meta)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == applicationautoscaling.ErrCodeFailedResourceAccessException {
return resource.RetryableError(err)
}
if isAWSErr(err, applicationautoscaling.ErrCodeFailedResourceAccessException, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
Expand Down Expand Up @@ -338,11 +336,10 @@ func resourceAwsAppautoscalingPolicyUpdate(d *schema.ResourceData, meta interfac
err := resource.Retry(2*time.Minute, func() *resource.RetryError {
_, err := conn.PutScalingPolicy(&params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == applicationautoscaling.ErrCodeFailedResourceAccessException {
return resource.RetryableError(err)
}
if isAWSErr(err, applicationautoscaling.ErrCodeFailedResourceAccessException, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
Expand Down Expand Up @@ -373,11 +370,10 @@ func resourceAwsAppautoscalingPolicyDelete(d *schema.ResourceData, meta interfac
err = resource.Retry(2*time.Minute, func() *resource.RetryError {
_, err = conn.DeleteScalingPolicy(&params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == applicationautoscaling.ErrCodeFailedResourceAccessException {
return resource.RetryableError(err)
}
if isAWSErr(err, applicationautoscaling.ErrCodeFailedResourceAccessException, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
Expand Down

0 comments on commit 83b6b39

Please sign in to comment.