fix(ec2): AssociateRouteTable associationState, RouteTable association filters, DescribeTags filters (#706)

- Include <associationState> in AssociateRouteTable response so Terraform
  v6 waiters can confirm association without timing out
- Add association.route-table-association-id, association.subnet-id,
  association.gateway-id, and association.main filter support to
  DescribeRouteTables
- Apply resource-id, resource-type, key, and value filters in DescribeTags
  (previously all filters were ignored, returning every tag)
- Add RouteTableAssociation.gatewayId field for gateway-id filter support
- Add integration tests covering new filters and associationState assertion
- Add VPC networking resources to compat-terraform and compat-opentofu
  suites (IGW, subnet, route table + association, security group)
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-05-05 00:11:51 -05:00
1 parent 7900cdbcb2
commit d620c18534
6 files changed
+263 -4

No files matched your search

@@ -948,6 +948,9 @@ public class Ec2QueryHandler {
.start("AssociateRouteTableResponse", AwsNamespaces.EC2)
.elem("requestId", UUID.randomUUID().toString())
.elem("associationId", assoc.getRouteTableAssociationId())
.start("associationState")
.elem("state", assoc.getAssociationState())
.end("associationState")
.end("AssociateRouteTableResponse");
return xmlResponse(xml.build());
}
@@ -924,13 +924,32 @@ public class Ec2Service {
public List<Map<String, String>> describeTags(String region, Map<String, List<String>> filters) {
ensureDefaultResources(region);
List<String> filterResourceIds = filters != null ? filters.get("resource-id") : null;
List<String> filterResourceTypes = filters != null ? filters.get("resource-type") : null;
List<String> filterKeys = filters != null ? filters.get("key") : null;
List<String> filterValues = filters != null ? filters.get("value") : null;
List<Map<String, String>> result = new ArrayList<>();
for (Map.Entry<String, List<Tag>> entry : tags.entrySet()) {
String resourceId = entry.getKey();
String resourceId = entry.getKey();
String resourceType = inferResourceType(resourceId);
if (filterResourceIds != null && !filterResourceIds.contains(resourceId)) {
continue;
}
if (filterResourceTypes != null && !filterResourceTypes.contains(resourceType)) {
continue;
}
for (Tag tag : entry.getValue()) {
if (filterKeys != null && !filterKeys.contains(tag.getKey())) {
continue;
}
if (filterValues != null && !filterValues.contains(tag.getValue())) {
continue;
}
Map<String, String> item = new LinkedHashMap<>();
item.put("resourceId", resourceId);
item.put("resourceType", inferResourceType(resourceId));
item.put("resourceType", resourceType);
item.put("key", tag.getKey());
item.put("value", tag.getValue());
result.add(item);
@@ -1270,6 +1289,14 @@ public class Ec2Service {
return switch (filterName) {
case "route-table-id" -> values.contains(rt.getRouteTableId());
case "vpc-id" -> values.contains(rt.getVpcId());
case "association.route-table-association-id" -> rt.getAssociations().stream()
.anyMatch(a -> values.contains(a.getRouteTableAssociationId()));
case "association.subnet-id" -> rt.getAssociations().stream()
.anyMatch(a -> a.getSubnetId() != null && values.contains(a.getSubnetId()));
case "association.gateway-id" -> rt.getAssociations().stream()
.anyMatch(a -> a.getGatewayId() != null && values.contains(a.getGatewayId()));
case "association.main" -> rt.getAssociations().stream()
.anyMatch(a -> values.contains(String.valueOf(a.isMain())));
default -> true;
};
}
@@ -10,6 +10,7 @@ public class RouteTableAssociation {
private String routeTableAssociationId;
private String routeTableId;
private String subnetId;
private String gatewayId;
private boolean main;
private String associationState = "associated";
@@ -24,6 +25,9 @@ public class RouteTableAssociation {
public String getSubnetId() { return subnetId; }
public void setSubnetId(String subnetId) { this.subnetId = subnetId; }
public String getGatewayId() { return gatewayId; }
public void setGatewayId(String gatewayId) { this.gatewayId = gatewayId; }
public boolean isMain() { return main; }
public void setMain(boolean main) { this.main = main; }