cdk-real-drift 0.9.8 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -283,7 +283,8 @@ snapshots its full live model and watches it, `ignore` accepts it, or `revert`
283
283
  - **AppSync**: data sources, resolvers, functions
284
284
  - **CloudWatch Logs**: metric filters, subscription filters
285
285
  - **ELBv2**: listeners, listener rules
286
- - **EC2**: VPC subnets, VPC endpoints, route table routes
286
+ - **EC2**: VPC subnets, VPC endpoints, VPC route tables, VPC network ACLs, route
287
+ table routes
287
288
  - **ECS**: cluster services
288
289
  - **KMS**: key aliases
289
290
  - **AppConfig**: application environments, configuration profiles
package/dist/cli.js CHANGED
@@ -7599,6 +7599,34 @@ function diffVpcEndpointChildren(input) {
7599
7599
  }
7600
7600
  return added;
7601
7601
  }
7602
+ function diffVpcRouteTableChildren(input) {
7603
+ const declared = new Set(input.declaredRouteTableIds);
7604
+ const added = [];
7605
+ for (const rt of input.liveRouteTables) {
7606
+ if (declared.has(rt.id)) continue;
7607
+ added.push({
7608
+ resourceType: "AWS::EC2::RouteTable",
7609
+ identifier: rt.id,
7610
+ label: rt.label ?? rt.id,
7611
+ live: { RouteTableId: rt.id }
7612
+ });
7613
+ }
7614
+ return added;
7615
+ }
7616
+ function diffVpcNaclChildren(input) {
7617
+ const declared = new Set(input.declaredNaclIds);
7618
+ const added = [];
7619
+ for (const n of input.liveNacls) {
7620
+ if (declared.has(n.id)) continue;
7621
+ added.push({
7622
+ resourceType: "AWS::EC2::NetworkAcl",
7623
+ identifier: n.id,
7624
+ label: n.label ?? n.id,
7625
+ live: { Id: n.id }
7626
+ });
7627
+ }
7628
+ return added;
7629
+ }
7602
7630
  async function pageSubnets(client, vpcId) {
7603
7631
  const out = [];
7604
7632
  let next;
@@ -7631,16 +7659,52 @@ async function pageVpcEndpoints(client, vpcId) {
7631
7659
  } while (next);
7632
7660
  return out;
7633
7661
  }
7662
+ async function pageVpcRouteTables(client, vpcId) {
7663
+ const out = [];
7664
+ let next;
7665
+ do {
7666
+ const res = await client.send(new DescribeRouteTablesCommand({
7667
+ Filters: [{
7668
+ Name: "vpc-id",
7669
+ Values: [vpcId]
7670
+ }],
7671
+ NextToken: next
7672
+ }));
7673
+ out.push(...res.RouteTables ?? []);
7674
+ next = res.NextToken;
7675
+ } while (next);
7676
+ return out;
7677
+ }
7678
+ async function pageNetworkAcls(client, vpcId) {
7679
+ const out = [];
7680
+ let next;
7681
+ do {
7682
+ const res = await client.send(new DescribeNetworkAclsCommand({
7683
+ Filters: [{
7684
+ Name: "vpc-id",
7685
+ Values: [vpcId]
7686
+ }],
7687
+ NextToken: next
7688
+ }));
7689
+ out.push(...res.NetworkAcls ?? []);
7690
+ next = res.NextToken;
7691
+ } while (next);
7692
+ return out;
7693
+ }
7634
7694
  async function enumerateVpcChildren(ctx) {
7635
7695
  const { parent, desired, region } = ctx;
7636
7696
  const vpcId = parent.physicalId;
7637
7697
  if (!vpcId) return [];
7638
7698
  const declaredSubnetIds = [];
7639
7699
  const declaredEndpointIds = [];
7700
+ const declaredRouteTableIds = [];
7701
+ const declaredNaclIds = [];
7640
7702
  for (const r of desired.resources) {
7641
7703
  if (!parentRefMatches(r.declared.VpcId, vpcId) || !r.physicalId) continue;
7642
7704
  if (r.resourceType === "AWS::EC2::Subnet") declaredSubnetIds.push(r.physicalId);
7643
7705
  else if (r.resourceType === "AWS::EC2::VPCEndpoint") declaredEndpointIds.push(r.physicalId);
7706
+ else if (r.resourceType === "AWS::EC2::RouteTable") declaredRouteTableIds.push(r.physicalId);
7707
+ else if (r.resourceType === "AWS::EC2::NetworkAcl") declaredNaclIds.push(r.physicalId);
7644
7708
  }
7645
7709
  const client = new EC2Client({
7646
7710
  region,
@@ -7654,13 +7718,32 @@ async function enumerateVpcChildren(ctx) {
7654
7718
  id: e.VpcEndpointId,
7655
7719
  label: e.ServiceName ?? e.VpcEndpointId
7656
7720
  }));
7657
- return [...diffVpcChildren({
7658
- declaredSubnetIds,
7659
- liveSubnets
7660
- }), ...diffVpcEndpointChildren({
7661
- declaredEndpointIds,
7662
- liveEndpoints
7663
- })];
7721
+ const liveRouteTables = (await pageVpcRouteTables(client, vpcId)).filter((rt) => typeof rt.RouteTableId === "string").filter((rt) => !(rt.Associations ?? []).some((a) => a.Main === true)).map((rt) => ({
7722
+ id: rt.RouteTableId,
7723
+ label: rt.RouteTableId
7724
+ }));
7725
+ const liveNacls = (await pageNetworkAcls(client, vpcId)).filter((n) => typeof n.NetworkAclId === "string").filter((n) => n.IsDefault !== true).map((n) => ({
7726
+ id: n.NetworkAclId,
7727
+ label: n.NetworkAclId
7728
+ }));
7729
+ return [
7730
+ ...diffVpcChildren({
7731
+ declaredSubnetIds,
7732
+ liveSubnets
7733
+ }),
7734
+ ...diffVpcEndpointChildren({
7735
+ declaredEndpointIds,
7736
+ liveEndpoints
7737
+ }),
7738
+ ...diffVpcRouteTableChildren({
7739
+ declaredRouteTableIds,
7740
+ liveRouteTables
7741
+ }),
7742
+ ...diffVpcNaclChildren({
7743
+ declaredNaclIds,
7744
+ liveNacls
7745
+ })
7746
+ ];
7664
7747
  }
7665
7748
  function diffRouteTableChildren(input) {
7666
7749
  const { routeTableId, declaredCidrs, liveRoutes, hasUnresolvedDeclaredRoute } = input;