fix(ec2): honor dry run for replace route (#4300)

This commit is contained in:
Aniket Shukla authored and GitHub committed 2026-09-24 08:31:11 -04:00
1 parent 876ddc7422
commit 55f9ff5a8b
3 files changed
+62 -1

No files matched your search

@@ -3651,7 +3651,8 @@ public class Ec2QueryHandler {
}
gwId = LOCAL_GATEWAY_ID;
}
service.replaceRoute(region, rtId, dest, destIpv6, destPrefixList, gwId, natGwId, pcxId);
service.replaceRoute(region, rtId, dest, destIpv6, destPrefixList, gwId, natGwId, pcxId,
Boolean.parseBoolean(p.getFirst("DryRun")));
return booleanResponse("ReplaceRoute");
}
@@ -7196,6 +7196,14 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {
public void replaceRoute(String region, String routeTableId, String destinationCidrBlock,
String destinationIpv6CidrBlock, String destinationPrefixListId,
String gatewayId, String natGatewayId, String vpcPeeringConnectionId) {
replaceRoute(region, routeTableId, destinationCidrBlock, destinationIpv6CidrBlock,
destinationPrefixListId, gatewayId, natGatewayId, vpcPeeringConnectionId, false);
}
public void replaceRoute(String region, String routeTableId, String destinationCidrBlock,
String destinationIpv6CidrBlock, String destinationPrefixListId,
String gatewayId, String natGatewayId, String vpcPeeringConnectionId,
boolean dryRun) {
requireExactlyOneDestination("ReplaceRoute", destinationCidrBlock, destinationIpv6CidrBlock,
destinationPrefixListId);
// AWS takes exactly one target. Rejecting both-or-neither also keeps the targets this
@@ -7225,6 +7233,11 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider {
destinationPrefixListId)
+ " does not exist", 400));
if (dryRun) {
throw new AwsException("DryRunOperation",
"Request would have succeeded, but DryRun flag is set.", 412);
}
// The target the request does not name is cleared rather than carried over from the
// route being replaced.
Route replacement = new Route(canonicalDestinationCidrBlock, hasGateway ? gatewayId : null, existing.getOrigin());