Don't error out when RDS DB instance disappears

This commit is contained in:
Alek Storm 2014-09-18 13:25:30 -07:00
parent ac2aed856e
commit f928829a1c
1 changed files with 12 additions and 7 deletions

View File

@ -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)
}
@ -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
}
}
@ -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
}
}