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

Final retries for RDS cluster functions #8994

Merged
merged 1 commit into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
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
19 changes: 18 additions & 1 deletion aws/resource_aws_rds_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
}
return nil
})
if isResourceTimeoutError(err) {
_, err = conn.RestoreDBClusterFromSnapshot(&opts)
}
if err != nil {
return fmt.Errorf("Error creating RDS Cluster: %s", err)
}
Expand Down Expand Up @@ -602,6 +605,9 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
}
return nil
})
if isResourceTimeoutError(err) {
resp, err = conn.CreateDBCluster(createOpts)
}
if err != nil {
return fmt.Errorf("error creating RDS cluster: %s", err)
}
Expand Down Expand Up @@ -695,8 +701,10 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error

log.Printf("[DEBUG] RDS Cluster restore options: %s", createOpts)
// Retry for IAM/S3 eventual consistency
var resp *rds.RestoreDBClusterFromS3Output
err := resource.Retry(5*time.Minute, func() *resource.RetryError {
resp, err := conn.RestoreDBClusterFromS3(createOpts)
var err error
resp, err = conn.RestoreDBClusterFromS3(createOpts)
if err != nil {
// InvalidParameterValue: Files from the specified Amazon S3 bucket cannot be downloaded.
// Make sure that you have created an AWS Identity and Access Management (IAM) role that lets Amazon RDS access Amazon S3 for you.
Expand All @@ -714,6 +722,9 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
log.Printf("[DEBUG]: RDS Cluster create response: %s", resp)
return nil
})
if isResourceTimeoutError(err) {
resp, err = conn.RestoreDBClusterFromS3(createOpts)
}

if err != nil {
log.Printf("[ERROR] Error creating RDS Cluster: %s", err)
Expand Down Expand Up @@ -837,6 +848,9 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error
}
return nil
})
if isResourceTimeoutError(err) {
resp, err = conn.CreateDBCluster(createOpts)
}
if err != nil {
return fmt.Errorf("error creating RDS cluster: %s", err)
}
Expand Down Expand Up @@ -1128,6 +1142,9 @@ func resourceAwsRDSClusterUpdate(d *schema.ResourceData, meta interface{}) error
}
return nil
})
if isResourceTimeoutError(err) {
_, err = conn.ModifyDBCluster(req)
}
if err != nil {
return fmt.Errorf("Failed to modify RDS Cluster (%s): %s", d.Id(), err)
}
Expand Down
6 changes: 6 additions & 0 deletions aws/resource_aws_rds_cluster_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ func resourceAwsRDSClusterInstanceCreate(d *schema.ResourceData, meta interface{
}
return nil
})
if isResourceTimeoutError(err) {
resp, err = conn.CreateDBInstance(createOpts)
}
if err != nil {
return fmt.Errorf("error creating RDS DB Instance: %s", err)
}
Expand Down Expand Up @@ -500,6 +503,9 @@ func resourceAwsRDSClusterInstanceUpdate(d *schema.ResourceData, meta interface{
}
return nil
})
if isResourceTimeoutError(err) {
_, err = conn.ModifyDBInstance(req)
}
if err != nil {
return fmt.Errorf("Error modifying DB Instance %s: %s", d.Id(), err)
}
Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_rds_global_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ func resourceAwsRDSGlobalClusterDelete(d *schema.ResourceData, meta interface{})
return nil
})

if isResourceTimeoutError(err) {
_, err = conn.DeleteGlobalCluster(input)
}

if isAWSErr(err, rds.ErrCodeGlobalClusterNotFoundFault, "") {
return nil
}
Expand Down