provider/aws: Add AWS error message to retry APIGateway acc update on (#8533)

This commit is contained in:
Radek Simko 2016-08-29 20:02:15 +01:00 committed by Paul Stack
parent 52eeaa0b72
commit 8317fe73d4
1 changed files with 4 additions and 4 deletions

View File

@ -6,7 +6,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/apigateway"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
@ -95,15 +94,16 @@ func resourceAwsApiGatewayAccountUpdate(d *schema.ResourceData, meta interface{}
// Retry due to eventual consistency of IAM
expectedErrMsg := "The role ARN does not have required permissions set to API Gateway"
otherErrMsg := "API Gateway could not successfully write to CloudWatch Logs using the ARN specified"
var out *apigateway.Account
var err error
err = resource.Retry(2*time.Minute, func() *resource.RetryError {
out, err = conn.UpdateAccount(&input)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "BadRequestException" &&
awsErr.Message() == expectedErrMsg {
log.Printf("[DEBUG] Retrying API Gateway Account update: %s", awsErr)
if isAWSErr(err, "BadRequestException", expectedErrMsg) ||
isAWSErr(err, "BadRequestException", otherErrMsg) {
log.Printf("[DEBUG] Retrying API Gateway Account update: %s", err)
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)