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

Don't error out when RDS DB instance disappears #307

Merged
merged 1 commit into from
Sep 30, 2014
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
19 changes: 12 additions & 7 deletions builtin/providers/aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ func resource_aws_db_instance_refresh(
if err != nil {
return s, err
}
if v == nil {
s.ID = ""
return s, nil
}

return resource_aws_db_instance_update_state(s, v)
}
Expand Down Expand Up @@ -305,13 +309,16 @@ func resource_aws_db_instance_retrieve(id string, conn *rds.Rds) (*rds.DBInstanc
resp, err := conn.DescribeDBInstances(&opts)

if err != nil {
if strings.Contains(err.Error(), "DBInstanceNotFound") {
return nil, nil
}
return nil, fmt.Errorf("Error retrieving DB Instances: %s", err)
}

if len(resp.DBInstances) != 1 ||
resp.DBInstances[0].DBInstanceIdentifier != id {
if err != nil {
return nil, fmt.Errorf("Unable to find DB Instance: %#v", resp.DBInstances)
return nil, nil
}
}

Expand Down Expand Up @@ -354,16 +361,14 @@ func DBInstanceStateRefreshFunc(id string, conn *rds.Rds) resource.StateRefreshF
v, err := resource_aws_db_instance_retrieve(id, conn)

if err != nil {
// We want to special-case "not found" instances because
// it could be waiting for it to be gone.
if strings.Contains(err.Error(), "DBInstanceNotFound") {
return nil, "", nil
}

log.Printf("Error on retrieving DB Instance when waiting: %s", err)
return nil, "", err
}

if v == nil {
return nil, "", nil
}

return v, v.DBInstanceStatus, nil
}
}