Merge pull request #8689 from erutherford/master

adding missing failed states for the NAT Gateways
This commit is contained in:
Paul Stack 2016-09-07 10:04:07 +01:00 committed by GitHub
commit 91ade752a0
2 changed files with 14 additions and 2 deletions

View File

@ -101,7 +101,14 @@ func resourceAwsNatGatewayRead(d *schema.ResourceData, meta interface{}) error {
if err != nil { if err != nil {
return err return err
} }
if ngRaw == nil || strings.ToLower(state) == "deleted" {
status := map[string]bool{
"deleted": true,
"deleting": true,
"failed": true,
}
if _, ok := status[strings.ToLower(state)]; ngRaw == nil || ok {
log.Printf("[INFO] Removing %s from Terraform state as it is not found or in the deleted state.", d.Id()) log.Printf("[INFO] Removing %s from Terraform state as it is not found or in the deleted state.", d.Id())
d.SetId("") d.SetId("")
return nil return nil

View File

@ -44,7 +44,12 @@ func testAccCheckNatGatewayDestroy(s *terraform.State) error {
NatGatewayIds: []*string{aws.String(rs.Primary.ID)}, NatGatewayIds: []*string{aws.String(rs.Primary.ID)},
}) })
if err == nil { if err == nil {
if len(resp.NatGateways) > 0 && strings.ToLower(*resp.NatGateways[0].State) != "deleted" { status := map[string]bool{
"deleted": true,
"deleting": true,
"failed": true,
}
if _, ok := status[strings.ToLower(*resp.NatGateways[0].State)]; len(resp.NatGateways) > 0 && !ok {
return fmt.Errorf("still exists") return fmt.Errorf("still exists")
} }