switch to go way of checking for key existence so that go doesn't crash when the value doesn't exist
This commit is contained in:
parent
04c2d40e57
commit
2cca48a829
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue