Merge pull request #1625 from hashicorp/b-panic-network-acl
provider/aws: fix potential panic when finding network ACL
This commit is contained in:
commit
341b2ff864
|
@ -185,7 +185,6 @@ func resourceAwsNetworkAclUpdate(d *schema.ResourceData, meta interface{}) error
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange("subnet_id") {
|
if d.HasChange("subnet_id") {
|
||||||
|
|
||||||
//associate new subnet with the acl.
|
//associate new subnet with the acl.
|
||||||
_, n := d.GetChange("subnet_id")
|
_, n := d.GetChange("subnet_id")
|
||||||
newSubnet := n.(string)
|
newSubnet := n.(string)
|
||||||
|
@ -355,10 +354,12 @@ func findNetworkAclAssociation(subnetId string, conn *ec2.EC2) (networkAclAssoci
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if resp.NetworkACLs != nil && len(resp.NetworkACLs) > 0 {
|
||||||
for _, association := range resp.NetworkACLs[0].Associations {
|
for _, association := range resp.NetworkACLs[0].Associations {
|
||||||
if *association.SubnetID == subnetId {
|
if *association.SubnetID == subnetId {
|
||||||
return association, nil
|
return association, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("could not find association for subnet %s ", subnetId)
|
return nil, fmt.Errorf("could not find association for subnet %s ", subnetId)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue