Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_rds_cluster: Add retries for IAM eventual consistency #4371

Merged
merged 1 commit into from
Apr 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 40 additions & 9 deletions aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,16 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
}

log.Printf("[DEBUG] RDS Cluster restore from snapshot configuration: %s", opts)
_, err := conn.RestoreDBClusterFromSnapshot(&opts)
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
_, err := conn.RestoreDBClusterFromSnapshot(&opts)
if err != nil {
if isAWSErr(err, "InvalidParameterValue", "IAM role ARN value is invalid or does not include the required permissions") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
return fmt.Errorf("Error creating RDS Cluster: %s", err)
}
Expand Down Expand Up @@ -424,10 +433,20 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
}

log.Printf("[DEBUG] Create RDS Cluster as read replica: %s", createOpts)
resp, err := conn.CreateDBCluster(createOpts)
var resp *rds.CreateDBClusterOutput
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
var err error
resp, err = conn.CreateDBCluster(createOpts)
if err != nil {
if isAWSErr(err, "InvalidParameterValue", "IAM role ARN value is invalid or does not include the required permissions") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
log.Printf("[ERROR] Error creating RDS Cluster: %s", err)
return err
return fmt.Errorf("error creating RDS cluster: %s", err)
}

log.Printf("[DEBUG]: RDS Cluster create response: %s", resp)
Expand Down Expand Up @@ -499,10 +518,20 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
}

log.Printf("[DEBUG] RDS Cluster create options: %s", createOpts)
resp, err := conn.CreateDBCluster(createOpts)
var resp *rds.CreateDBClusterOutput
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
var err error
resp, err = conn.CreateDBCluster(createOpts)
if err != nil {
if isAWSErr(err, "InvalidParameterValue", "IAM role ARN value is invalid or does not include the required permissions") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
log.Printf("[ERROR] Error creating RDS Cluster: %s", err)
return err
return fmt.Errorf("error creating RDS cluster: %s", err)
}

log.Printf("[DEBUG]: RDS Cluster create response: %s", resp)
Expand Down Expand Up @@ -704,8 +733,10 @@ func resourceAwsRDSClusterUpdate(d *schema.ResourceData, meta interface{}) error
err := resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err := conn.ModifyDBCluster(req)
if err != nil {
awsErr, ok := err.(awserr.Error)
if ok && awsErr.Code() == rds.ErrCodeInvalidDBClusterStateFault {
if isAWSErr(err, "InvalidParameterValue", "IAM role ARN value is invalid or does not include the required permissions") {
return resource.RetryableError(err)
}
if isAWSErr(err, rds.ErrCodeInvalidDBClusterStateFault, "") {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
Expand Down