cdk-real-drift 0.9.0 → 0.9.1

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,7 @@ 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, route table routes
286
+ - **EC2**: VPC subnets, VPC endpoints, route table routes
287
287
  - **ECS**: cluster services
288
288
  - **KMS**: key aliases
289
289
  - **AppConfig**: application environments, configuration profiles
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ import { AppSyncClient, ListApiKeysCommand, ListDataSourcesCommand, ListFunction
18
18
  import { ApiGatewayV2Client, DeleteAccessLogSettingsCommand, DeleteRouteSettingsCommand, GetAuthorizersCommand as GetAuthorizersCommand$1, GetIntegrationsCommand, GetRoutesCommand, GetStagesCommand as GetStagesCommand$1, UpdateStageCommand } from "@aws-sdk/client-apigatewayv2";
19
19
  import { CloudWatchLogsClient, DescribeMetricFiltersCommand, DescribeSubscriptionFiltersCommand, PutBearerTokenAuthenticationCommand, PutMetricFilterCommand } from "@aws-sdk/client-cloudwatch-logs";
20
20
  import { CognitoIdentityProviderClient, ListGroupsCommand, ListResourceServersCommand, ListUserPoolClientsCommand } from "@aws-sdk/client-cognito-identity-provider";
21
- import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSubnetsCommand, EC2Client, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
21
+ import { DescribeAddressesCommand, DescribeClientVpnAuthorizationRulesCommand, DescribeClientVpnEndpointsCommand, DescribeClientVpnTargetNetworksCommand, DescribeLaunchTemplateVersionsCommand, DescribeNetworkAclsCommand, DescribeRouteTablesCommand, DescribeSubnetsCommand, DescribeVpcEndpointsCommand, EC2Client, ModifyClientVpnEndpointCommand } from "@aws-sdk/client-ec2";
22
22
  import { DescribeServicesCommand, ECSClient, ListServicesCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
23
23
  import { DescribeMountTargetsCommand, EFSClient } from "@aws-sdk/client-efs";
24
24
  import { DescribeListenersCommand, DescribeRulesCommand, ElasticLoadBalancingV2Client, GetTrustStoreCaCertificatesBundleCommand, ModifyLoadBalancerAttributesCommand, ModifyTargetGroupAttributesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";
@@ -7444,6 +7444,20 @@ function diffVpcChildren(input) {
7444
7444
  }
7445
7445
  return added;
7446
7446
  }
7447
+ function diffVpcEndpointChildren(input) {
7448
+ const declared = new Set(input.declaredEndpointIds);
7449
+ const added = [];
7450
+ for (const e of input.liveEndpoints) {
7451
+ if (declared.has(e.id)) continue;
7452
+ added.push({
7453
+ resourceType: "AWS::EC2::VPCEndpoint",
7454
+ identifier: e.id,
7455
+ label: e.label ?? e.id,
7456
+ live: { Id: e.id }
7457
+ });
7458
+ }
7459
+ return added;
7460
+ }
7447
7461
  async function pageSubnets(client, vpcId) {
7448
7462
  const out = [];
7449
7463
  let next;
@@ -7460,22 +7474,52 @@ async function pageSubnets(client, vpcId) {
7460
7474
  } while (next);
7461
7475
  return out;
7462
7476
  }
7477
+ async function pageVpcEndpoints(client, vpcId) {
7478
+ const out = [];
7479
+ let next;
7480
+ do {
7481
+ const res = await client.send(new DescribeVpcEndpointsCommand({
7482
+ Filters: [{
7483
+ Name: "vpc-id",
7484
+ Values: [vpcId]
7485
+ }],
7486
+ NextToken: next
7487
+ }));
7488
+ out.push(...res.VpcEndpoints ?? []);
7489
+ next = res.NextToken;
7490
+ } while (next);
7491
+ return out;
7492
+ }
7463
7493
  async function enumerateVpcChildren(ctx) {
7464
7494
  const { parent, desired, region } = ctx;
7465
7495
  const vpcId = parent.physicalId;
7466
7496
  if (!vpcId) return [];
7467
7497
  const declaredSubnetIds = [];
7468
- for (const r of desired.resources) if (r.resourceType === "AWS::EC2::Subnet" && parentRefMatches(r.declared.VpcId, vpcId) && r.physicalId) declaredSubnetIds.push(r.physicalId);
7469
- return diffVpcChildren({
7470
- declaredSubnetIds,
7471
- liveSubnets: (await pageSubnets(new EC2Client({
7472
- region,
7473
- ...READ_RETRY
7474
- }), vpcId)).filter((s) => typeof s.SubnetId === "string").map((s) => ({
7475
- id: s.SubnetId,
7476
- label: s.CidrBlock ? `${s.CidrBlock}` : s.SubnetId
7477
- }))
7498
+ const declaredEndpointIds = [];
7499
+ for (const r of desired.resources) {
7500
+ if (!parentRefMatches(r.declared.VpcId, vpcId) || !r.physicalId) continue;
7501
+ if (r.resourceType === "AWS::EC2::Subnet") declaredSubnetIds.push(r.physicalId);
7502
+ else if (r.resourceType === "AWS::EC2::VPCEndpoint") declaredEndpointIds.push(r.physicalId);
7503
+ }
7504
+ const client = new EC2Client({
7505
+ region,
7506
+ ...READ_RETRY
7478
7507
  });
7508
+ const liveSubnets = (await pageSubnets(client, vpcId)).filter((s) => typeof s.SubnetId === "string").map((s) => ({
7509
+ id: s.SubnetId,
7510
+ label: s.CidrBlock ? `${s.CidrBlock}` : s.SubnetId
7511
+ }));
7512
+ const liveEndpoints = (await pageVpcEndpoints(client, vpcId)).filter((e) => typeof e.VpcEndpointId === "string").map((e) => ({
7513
+ id: e.VpcEndpointId,
7514
+ label: e.ServiceName ?? e.VpcEndpointId
7515
+ }));
7516
+ return [...diffVpcChildren({
7517
+ declaredSubnetIds,
7518
+ liveSubnets
7519
+ }), ...diffVpcEndpointChildren({
7520
+ declaredEndpointIds,
7521
+ liveEndpoints
7522
+ })];
7479
7523
  }
7480
7524
  function diffRouteTableChildren(input) {
7481
7525
  const { routeTableId, declaredCidrs, liveRoutes, hasUnresolvedDeclaredRoute } = input;