cdk-real-drift 0.12.4 → 0.12.6

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/dist/cli.js CHANGED
@@ -1643,6 +1643,7 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1643
1643
  const sgSibling = resource.resourceType === "AWS::EC2::SecurityGroup" && resource.physicalId ? opts.siblingSgRules?.[resource.physicalId] : void 0;
1644
1644
  const bucketNotif = resource.physicalId && opts.bucketNotificationManaged?.has(resource.physicalId) ? [resource.physicalId] : void 0;
1645
1645
  const eipSiblingId = resource.physicalId && opts.siblingEipAssociations?.has(resource.physicalId) ? resource.physicalId : opts.siblingEipAssociations?.has(resource.logicalId) ? resource.logicalId : void 0;
1646
+ const tgRegistrarId = resource.physicalId && opts.siblingTargetGroupRegistrars?.has(resource.physicalId) ? resource.physicalId : opts.siblingTargetGroupRegistrars?.has(resource.logicalId) ? resource.logicalId : void 0;
1646
1647
  const echoModel = resource.physicalId && opts.clusterEchoModel?.[resource.physicalId] ? opts.clusterEchoModel[resource.physicalId] : void 0;
1647
1648
  const rdsOptCatalog = resource.physicalId && opts.rdsOptionSettingDefaults?.[resource.physicalId] ? opts.rdsOptionSettingDefaults[resource.physicalId] : void 0;
1648
1649
  const listenerArn = resource.resourceType === "AWS::GlobalAccelerator::EndpointGroup" ? resource.declared?.ListenerArn : void 0;
@@ -1679,6 +1680,7 @@ function buildCorpusCase(resource, liveRaw, schema, opts, findings) {
1679
1680
  ...sgSibling && resource.physicalId ? { siblingSgRules: { [resource.physicalId]: sgSibling } } : {},
1680
1681
  ...bucketNotif ? { bucketNotificationManaged: bucketNotif } : {},
1681
1682
  ...eipSiblingId ? { siblingEipAssociations: [eipSiblingId] } : {},
1683
+ ...tgRegistrarId ? { siblingTargetGroupRegistrars: [tgRegistrarId] } : {},
1682
1684
  ...echoModel && resource.physicalId ? { clusterEchoModel: { [resource.physicalId]: echoModel } } : {},
1683
1685
  ...rdsOptCatalog && resource.physicalId ? { rdsOptionSettingDefaults: { [resource.physicalId]: rdsOptCatalog } } : {},
1684
1686
  ...gaListenerPort ? { siblingListenerPorts: gaListenerPort } : {}
@@ -2884,7 +2886,6 @@ const GENERATED_TOPLEVEL_PATHS = {
2884
2886
  "AWS::EC2::SecurityGroupIngress": new Set(["SourceSecurityGroupOwnerId", "GroupName"]),
2885
2887
  "AWS::ECS::Service": new Set(["Role"]),
2886
2888
  "AWS::SecretsManager::Secret": new Set(["Name"]),
2887
- "AWS::ElasticLoadBalancingV2::TargetGroup": new Set(["Targets"]),
2888
2889
  "AWS::ApplicationAutoScaling::ScalingPolicy": new Set([
2889
2890
  "ResourceId",
2890
2891
  "ServiceNamespace",
@@ -5120,7 +5121,8 @@ function guardDutyFeaturesAllAtDefault(features) {
5120
5121
  }
5121
5122
  const DEFAULT_SG_LIST_PATHS = {
5122
5123
  "AWS::ElasticLoadBalancingV2::LoadBalancer": "SecurityGroups",
5123
- "AWS::EC2::NetworkInterface": "GroupSet"
5124
+ "AWS::EC2::NetworkInterface": "GroupSet",
5125
+ "AWS::Neptune::DBCluster": "VpcSecurityGroupIds"
5124
5126
  };
5125
5127
  /** #889 fold decision for an UNDECLARED default-SG list (ALB SecurityGroups / ENI GroupSet).
5126
5128
  * Returns whether the value-independent fold should still apply for this live value:
@@ -5152,6 +5154,7 @@ const IDENTITY_KEYED_SUBSET_ARRAYS = {
5152
5154
  foldHuskExtras: true
5153
5155
  } }
5154
5156
  };
5157
+ const VALUE_INDEPENDENT_KEYED_ELEMENTS = { "AWS::Cognito::UserPoolUser": { UserAttributes: new Set(["sub"]) } };
5155
5158
  const NESTED_ARRAY_IDENTITY = {
5156
5159
  "AWS::ApiGateway::Method": {
5157
5160
  "Integration.IntegrationResponses": "StatusCode",
@@ -6195,7 +6198,9 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6195
6198
  for (const lEl of live[k]) {
6196
6199
  const id = idOf(lEl);
6197
6200
  if (id !== void 0 && !declaredIds.has(id)) {
6198
- const atDefault = subsetSpec.foldHuskExtras === true && isNestedObject(lEl) && Object.entries(lEl).every(([ek, ev]) => ek === idField || isTrivialEmpty(ev)) || defaultEls && id in defaultEls && deepEqual(lEl, defaultEls[id]);
6201
+ const isHuskExtra = subsetSpec.foldHuskExtras === true && isNestedObject(lEl) && Object.entries(lEl).every(([ek, ev]) => ek === idField || isTrivialEmpty(ev));
6202
+ const isValueIndependentId = VALUE_INDEPENDENT_KEYED_ELEMENTS[resourceType]?.[k]?.has(id) ?? false;
6203
+ const atDefault = isHuskExtra || isValueIndependentId || defaultEls && id in defaultEls && deepEqual(lEl, defaultEls[id]);
6199
6204
  findings.push({
6200
6205
  tier: atDefault ? "atDefault" : "undeclared",
6201
6206
  logicalId,
@@ -6514,6 +6519,16 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6514
6519
  });
6515
6520
  continue;
6516
6521
  }
6522
+ if (resourceType === "AWS::ElasticLoadBalancingV2::TargetGroup" && k === "Targets" && (physicalId !== void 0 && opts.siblingTargetGroupRegistrars?.has(physicalId) || opts.siblingTargetGroupRegistrars?.has(logicalId))) {
6523
+ findings.push({
6524
+ tier: "generated",
6525
+ logicalId,
6526
+ resourceType,
6527
+ path: k,
6528
+ actual: v
6529
+ });
6530
+ continue;
6531
+ }
6517
6532
  if (isAllAwsTags(v)) continue;
6518
6533
  if (physicalId !== void 0 && v === physicalId) continue;
6519
6534
  const offStateIsMeaningful = k in knownDef && !matchesKnownDefault(v, knownDef[k]) && (MEANINGFUL_WHEN_OFF[resourceType]?.[k]?.({
@@ -6527,7 +6542,8 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6527
6542
  }
6528
6543
  const subsetSpecU = IDENTITY_KEYED_SUBSET_ARRAYS[resourceType]?.[k];
6529
6544
  const defaultElsU = IDENTITY_KEYED_DEFAULT_ELEMENTS[resourceType]?.[k];
6530
- if (subsetSpecU !== void 0 && defaultElsU !== void 0 && Array.isArray(v)) {
6545
+ const viIdsU = VALUE_INDEPENDENT_KEYED_ELEMENTS[resourceType]?.[k];
6546
+ if (subsetSpecU !== void 0 && (defaultElsU !== void 0 || viIdsU !== void 0) && Array.isArray(v)) {
6531
6547
  const { idField, normalizeId } = subsetSpecU;
6532
6548
  for (const lEl of v) {
6533
6549
  if (!isNestedObject(lEl) || typeof lEl[idField] !== "string") {
@@ -6542,7 +6558,7 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
6542
6558
  }
6543
6559
  const raw = lEl[idField];
6544
6560
  const id = normalizeId ? normalizeId(raw) : raw;
6545
- const atDefault = id in defaultElsU && deepEqual(lEl, defaultElsU[id]);
6561
+ const atDefault = (viIdsU?.has(id) ?? false) || defaultElsU !== void 0 && id in defaultElsU && deepEqual(lEl, defaultElsU[id]);
6546
6562
  findings.push({
6547
6563
  tier: atDefault ? "atDefault" : "undeclared",
6548
6564
  logicalId,
@@ -11039,7 +11055,11 @@ function liveModelMap(reads) {
11039
11055
  for (const [logicalId, read] of reads) if (read.live) out.set(logicalId, read.live);
11040
11056
  return out;
11041
11057
  }
11042
- const DEFAULT_SG_LIST_TYPES = new Set(["AWS::ElasticLoadBalancingV2::LoadBalancer", "AWS::EC2::NetworkInterface"]);
11058
+ const DEFAULT_SG_LIST_TYPES = new Set([
11059
+ "AWS::ElasticLoadBalancingV2::LoadBalancer",
11060
+ "AWS::EC2::NetworkInterface",
11061
+ "AWS::Neptune::DBCluster"
11062
+ ]);
11043
11063
  const defaultSgIdsCache = /* @__PURE__ */ new Map();
11044
11064
  async function fetchDefaultSgIds(region) {
11045
11065
  const cached = defaultSgIdsCache.get(region);
@@ -11369,6 +11389,61 @@ function buildSiblingEipAssociations(desired) {
11369
11389
  }
11370
11390
  return associated;
11371
11391
  }
11392
+ const ECS_SERVICE_TYPE = "AWS::ECS::Service";
11393
+ const AUTO_SCALING_GROUP_TYPE = "AWS::AutoScaling::AutoScalingGroup";
11394
+ const TARGET_GROUP_TYPE = "AWS::ElasticLoadBalancingV2::TargetGroup";
11395
+ function buildSiblingTargetGroupRegistrars(desired) {
11396
+ const tgIdentitiesByLogicalId = /* @__PURE__ */ new Map();
11397
+ const tgLogicalIdByPhysicalId = /* @__PURE__ */ new Map();
11398
+ for (const r of desired.resources) {
11399
+ if (r.resourceType !== TARGET_GROUP_TYPE) continue;
11400
+ const ids = [r.logicalId];
11401
+ if (r.physicalId) {
11402
+ ids.push(r.physicalId);
11403
+ tgLogicalIdByPhysicalId.set(r.physicalId, r.logicalId);
11404
+ }
11405
+ tgIdentitiesByLogicalId.set(r.logicalId, ids);
11406
+ }
11407
+ const registered = /* @__PURE__ */ new Set();
11408
+ const markTg = (ref) => {
11409
+ let tgLogicalId;
11410
+ if (ref && typeof ref === "object") {
11411
+ if ("Ref" in ref && typeof ref.Ref === "string") tgLogicalId = ref.Ref;
11412
+ else if ("Fn::GetAtt" in ref) {
11413
+ const g = ref["Fn::GetAtt"];
11414
+ if (Array.isArray(g) && typeof g[0] === "string") tgLogicalId = g[0];
11415
+ }
11416
+ }
11417
+ if (tgLogicalId !== void 0) {
11418
+ const ids = tgIdentitiesByLogicalId.get(tgLogicalId);
11419
+ if (ids) for (const id of ids) registered.add(id);
11420
+ return;
11421
+ }
11422
+ if (typeof ref === "string" && ref) {
11423
+ registered.add(ref);
11424
+ const logicalId = tgLogicalIdByPhysicalId.get(ref);
11425
+ if (logicalId) registered.add(logicalId);
11426
+ }
11427
+ };
11428
+ for (const r of desired.resources) {
11429
+ const decl = r.declared;
11430
+ if (!decl || typeof decl !== "object") continue;
11431
+ const d = decl;
11432
+ if (r.resourceType === ECS_SERVICE_TYPE) {
11433
+ const lbs = d.LoadBalancers;
11434
+ if (Array.isArray(lbs)) {
11435
+ for (const lb of lbs) if (lb && typeof lb === "object") markTg(lb.TargetGroupArn);
11436
+ }
11437
+ } else if (r.resourceType === AUTO_SCALING_GROUP_TYPE) {
11438
+ const arns = d.TargetGroupARNs;
11439
+ if (Array.isArray(arns)) for (const arn of arns) markTg(arn);
11440
+ } else if (r.resourceType === TARGET_GROUP_TYPE && d.TargetType === "lambda") {
11441
+ const ids = tgIdentitiesByLogicalId.get(r.logicalId);
11442
+ if (ids) for (const id of ids) registered.add(id);
11443
+ }
11444
+ }
11445
+ return registered;
11446
+ }
11372
11447
  function buildClusterEchoModels(desired) {
11373
11448
  const parentTypes = new Set(Object.values(CLUSTER_ECHO_CHILD).map((s) => s.parentType));
11374
11449
  const clusterByPhys = {};
@@ -11580,6 +11655,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
11580
11655
  siblingLifecycleHooks: buildSiblingLifecycleHooks(desired),
11581
11656
  siblingListenerPorts: buildSiblingListenerPorts(desired),
11582
11657
  siblingEipAssociations: buildSiblingEipAssociations(desired),
11658
+ siblingTargetGroupRegistrars: buildSiblingTargetGroupRegistrars(desired),
11583
11659
  bucketNotificationManaged: buildBucketNotificationManaged(desired),
11584
11660
  clusterEchoModel: buildClusterEchoModels(desired),
11585
11661
  rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)
@@ -11648,6 +11724,7 @@ async function regatherTouched(gathered, touched, region) {
11648
11724
  siblingLifecycleHooks: buildSiblingLifecycleHooks(desired),
11649
11725
  siblingListenerPorts: buildSiblingListenerPorts(desired),
11650
11726
  siblingEipAssociations: buildSiblingEipAssociations(desired),
11727
+ siblingTargetGroupRegistrars: buildSiblingTargetGroupRegistrars(desired),
11651
11728
  bucketNotificationManaged: buildBucketNotificationManaged(desired),
11652
11729
  clusterEchoModel: buildClusterEchoModels(desired),
11653
11730
  rdsOptionSettingDefaults: await buildRdsOptionSettingDefaults(desired, region)