diff --git a/builtin/providers/aws/resource_aws_nat_gateway.go b/builtin/providers/aws/resource_aws_nat_gateway.go index deabc7297..1ec5e986e 100644 --- a/builtin/providers/aws/resource_aws_nat_gateway.go +++ b/builtin/providers/aws/resource_aws_nat_gateway.go @@ -108,7 +108,7 @@ func resourceAwsNatGatewayRead(d *schema.ResourceData, meta interface{}) error { "failed": true, } - if ngRaw == nil || status[strings.ToLower(state)] { + 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()) d.SetId("") return nil diff --git a/builtin/providers/aws/resource_aws_nat_gateway_test.go b/builtin/providers/aws/resource_aws_nat_gateway_test.go index 96aac1625..dac50527c 100644 --- a/builtin/providers/aws/resource_aws_nat_gateway_test.go +++ b/builtin/providers/aws/resource_aws_nat_gateway_test.go @@ -43,13 +43,13 @@ func testAccCheckNatGatewayDestroy(s *terraform.State) error { resp, err := conn.DescribeNatGateways(&ec2.DescribeNatGatewaysInput{ NatGatewayIds: []*string{aws.String(rs.Primary.ID)}, }) - status := map[string]bool{ - "deleted": false, - "deleting": false, - "failed": false, - } if err == nil { - if len(resp.NatGateways) > 0 && status[strings.ToLower(*resp.NatGateways[0].State)] { + 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") }