Skip to content

Commit

Permalink
Merge pull request #1625 from hashicorp/b-panic-network-acl
Browse files Browse the repository at this point in the history
provider/aws: fix potential panic when finding network ACL
  • Loading branch information
mitchellh committed Apr 22, 2015
2 parents 791f59e + f77f77f commit 341b2ff
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions builtin/providers/aws/resource_aws_network_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func resourceAwsNetworkAclUpdate(d *schema.ResourceData, meta interface{}) error
}

if d.HasChange("subnet_id") {

//associate new subnet with the acl.
_, n := d.GetChange("subnet_id")
newSubnet := n.(string)
Expand Down Expand Up @@ -355,9 +354,11 @@ func findNetworkAclAssociation(subnetId string, conn *ec2.EC2) (networkAclAssoci
if err != nil {
return nil, err
}
for _, association := range resp.NetworkACLs[0].Associations {
if *association.SubnetID == subnetId {
return association, nil
if resp.NetworkACLs != nil && len(resp.NetworkACLs) > 0 {
for _, association := range resp.NetworkACLs[0].Associations {
if *association.SubnetID == subnetId {
return association, nil
}
}
}
return nil, fmt.Errorf("could not find association for subnet %s ", subnetId)
Expand Down

0 comments on commit 341b2ff

Please sign in to comment.