moving to using a map to clean up the error check
This commit is contained in:
parent
7a6b04dfa2
commit
91f6f2a143
|
@ -101,7 +101,14 @@ func resourceAwsNatGatewayRead(d *schema.ResourceData, meta interface{}) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ngRaw == nil || strings.ToLower(state) == "deleted" || strings.ToLower(state) == "deleting" || strings.ToLower(state) == "failed" {
|
||||
|
||||
status := map[string]bool {
|
||||
"deleted": true,
|
||||
"deleting": true,
|
||||
"failed": true,
|
||||
}
|
||||
|
||||
if ngRaw == nil || status[strings.ToLower(state)] {
|
||||
log.Printf("[INFO] Removing %s from Terraform state as it is not found or in the deleted state.", d.Id())
|
||||
d.SetId("")
|
||||
return nil
|
||||
|
|
|
@ -43,8 +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 && strings.ToLower(*resp.NatGateways[0].State) != "deleted" && strings.ToLower(*resp.NatGateways[0].State) != "deleting" && strings.ToLower(*resp.NatGateways[0].State) != "failed" {
|
||||
if len(resp.NatGateways) > 0 && status[strings.ToLower(*resp.NatGateways[0].State)] {
|
||||
return fmt.Errorf("still exists")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue