mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-17 12:12:59 -06:00
provider/aws: fix potential panic when finding network ACL
This commit is contained in:
parent
a27890b1a6
commit
f77f77f9f8
@ -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,9 +354,11 @@ func findNetworkAclAssociation(subnetId string, conn *ec2.EC2) (networkAclAssoci
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, association := range resp.NetworkACLs[0].Associations {
|
if resp.NetworkACLs != nil && len(resp.NetworkACLs) > 0 {
|
||||||
if *association.SubnetID == subnetId {
|
for _, association := range resp.NetworkACLs[0].Associations {
|
||||||
return association, nil
|
if *association.SubnetID == subnetId {
|
||||||
|
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
Block a user