fix(ec2): guard null group entries in DescribeNetworkInterfaces group-id filter (#2887)

The group-id filter dereferenced each of an interface's group entries with no
null check, unlike the sibling filters in the same switch (attachment.instance-id
already guards getAttachment() != null). When an interface's group list carried a
null entry, matchesFilter threw a NullPointerException and DescribeNetworkInterfaces
returned a 500.

Terraform and Pulumi poll DescribeNetworkInterfaces filtered by group-id while
deleting a security group, so the 500 turned an SG delete into an indefinite retry
loop until the client timed out. Guard each entry, matching the null-tolerant style
of the adjacent cases.
This commit is contained in:
Matan Baruch authored and GitHub committed 2026-09-02 10:16:59 -04:00
1 parent e44df51a79
commit 5c71713cad
2 files changed
+24 -1

No files matched your search

@@ -5968,7 +5968,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {
case "subnet-id" -> matchesValue(values, ni.getSubnetId());
case "vpc-id" -> matchesValue(values, ni.getVpcId());
case "group-id" -> ni.getGroups().stream()
.anyMatch(g -> matchesValue(values, g.getGroupId()));
.anyMatch(g -> g != null && matchesValue(values, g.getGroupId()));
case "status" -> matchesValue(values, ni.getStatus());
case "attachment.instance-id" -> ni.getAttachment() != null
&& matchesValue(values, ni.getAttachment().getInstanceId());