fix(ec2): match cidr-block-association filters on DescribeVpcs (#3257)

DescribeVpcs silently ignored the cidr-block-association.* and
ipv6-cidr-block-association.* filters: unrecognized filter names fell
through matchesFilter's default -> true, so every VPC in the account
matched regardless of the requested association.

terraform-provider-aws's waiter for aws_vpc_ipv4_cidr_block_association
polls DescribeVpcs filtered by cidr-block-association.association-id and
asserts exactly one VPC comes back. With more than one VPC in the
account that assertion failed with a too-many-results error, which the
SDK's retry machinery treats as not-found-yet rather than a fatal error,
so the waiter retried until its create timeout, hanging terraform apply
on any secondary_cidr_blocks entry.

Fixes #3256
This commit is contained in:
Angel Abad authored and GitHub committed 2026-09-08 23:26:09 -05:00
1 parent f4954dec02
commit eb3a6b23ef
2 files changed
+297

No files matched your search

@@ -6181,6 +6181,18 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {
// 2026-08-25: it matches only the primary block, not a secondary
// cidr-block-association entry).
case "cidr", "cidr-block" -> matchesValue(values, vpc.getCidrBlock());
case "cidr-block-association.association-id" -> vpc.getCidrBlockAssociationSet().stream()
.anyMatch(a -> matchesValue(values, a.getAssociationId()));
case "cidr-block-association.cidr-block" -> vpc.getCidrBlockAssociationSet().stream()
.anyMatch(a -> matchesValue(values, a.getCidrBlock()));
case "cidr-block-association.state" -> vpc.getCidrBlockAssociationSet().stream()
.anyMatch(a -> matchesValue(values, a.getCidrBlockState()));
case "ipv6-cidr-block-association.association-id" -> vpc.getIpv6CidrBlockAssociationSet().stream()
.anyMatch(a -> matchesValue(values, a.getAssociationId()));
case "ipv6-cidr-block-association.ipv6-cidr-block" -> vpc.getIpv6CidrBlockAssociationSet().stream()
.anyMatch(a -> matchesValue(values, a.getIpv6CidrBlock()));
case "ipv6-cidr-block-association.state" -> vpc.getIpv6CidrBlockAssociationSet().stream()
.anyMatch(a -> matchesValue(values, a.getIpv6CidrBlockState()));
default -> true;
};
}