Skip to content

Commit

Permalink
Retry app autoscaling policy create/update on ObjectNotFound error
Browse files Browse the repository at this point in the history
  • Loading branch information
tomelliff committed Apr 10, 2019
1 parent 409a3dc commit d082965
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions aws/resource_aws_appautoscaling_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,16 @@ func resourceAwsAppautoscalingPolicyCreate(d *schema.ResourceData, meta interfac
var err error
resp, err = conn.PutScalingPolicy(&params)
if err != nil {
if isAWSErr(err, "FailedResourceAccessException", "Rate exceeded") {
if isAWSErr(err, applicationautoscaling.ErrCodeFailedResourceAccessException, "Rate exceeded") {
return resource.RetryableError(err)
}
if isAWSErr(err, "FailedResourceAccessException", "is not authorized to perform") {
if isAWSErr(err, applicationautoscaling.ErrCodeFailedResourceAccessException, "is not authorized to perform") {
return resource.RetryableError(err)
}
if isAWSErr(err, "FailedResourceAccessException", "token included in the request is invalid") {
if isAWSErr(err, applicationautoscaling.ErrCodeFailedResourceAccessException, "token included in the request is invalid") {
return resource.RetryableError(err)
}
if isAWSErr(err, applicationautoscaling.ErrCodeObjectNotFoundException, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(fmt.Errorf("Error putting scaling policy: %s", err))
Expand Down Expand Up @@ -343,6 +346,9 @@ func resourceAwsAppautoscalingPolicyUpdate(d *schema.ResourceData, meta interfac
if isAWSErr(err, applicationautoscaling.ErrCodeFailedResourceAccessException, "") {
return resource.RetryableError(err)
}
if isAWSErr(err, applicationautoscaling.ErrCodeObjectNotFoundException, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
Expand Down

0 comments on commit d082965

Please sign in to comment.