cdk-real-drift 0.2.30 → 0.2.31

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
@@ -5,7 +5,7 @@ import { dirname, join, resolve } from "node:path";
5
5
  import { YAMLSeq, isSeq, parse, parseDocument } from "yaml";
6
6
  import { CloudControlClient, DeleteResourceCommand, GetResourceCommand, GetResourceRequestStatusCommand, UpdateResourceCommand } from "@aws-sdk/client-cloudcontrol";
7
7
  import { BaseCredentials, CdkAppMultiContext, NonInteractiveIoHost, Toolkit } from "@aws-cdk/toolkit-lib";
8
- import { CloudFormationClient, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
8
+ import { CloudFormationClient, DescribeStackResourcesCommand, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
9
9
  import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
10
10
  import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
11
11
  import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
@@ -8222,6 +8222,20 @@ async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
8222
8222
  };
8223
8223
  }
8224
8224
  }
8225
+ async function isManagedBySiblingStack(cfn, c, cache) {
8226
+ const physicalId = c.identifier;
8227
+ if (physicalId.includes("|")) return false;
8228
+ const cached = cache.get(physicalId);
8229
+ if (cached !== void 0) return cached;
8230
+ let managed = false;
8231
+ try {
8232
+ managed = ((await cfn.send(new DescribeStackResourcesCommand({ PhysicalResourceId: physicalId }))).StackResources ?? []).some((r) => r.PhysicalResourceId === physicalId && r.ResourceType === c.resourceType);
8233
+ } catch {
8234
+ managed = false;
8235
+ }
8236
+ cache.set(physicalId, managed);
8237
+ return managed;
8238
+ }
8225
8239
  const SG_RULE_RESOURCE_SIDE = {
8226
8240
  "AWS::EC2::SecurityGroupIngress": "ingress",
8227
8241
  "AWS::EC2::SecurityGroupEgress": "egress"
@@ -8344,6 +8358,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
8344
8358
  for (const r of desired.resources) if (r.declaredRaw) r.declared = resolveProperties(r.declaredRaw, desired.ctx);
8345
8359
  }
8346
8360
  const oaiCanonicalIds = buildOaiCanonicalIds(desired);
8361
+ const siblingStackCache = /* @__PURE__ */ new Map();
8347
8362
  for (const r of desired.resources) {
8348
8363
  const enumerate = CHILD_ENUMERATORS[r.resourceType];
8349
8364
  if (!enumerate || !r.physicalId) continue;
@@ -8355,6 +8370,7 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
8355
8370
  region
8356
8371
  });
8357
8372
  for (const c of children) {
8373
+ if (await isManagedBySiblingStack(cfn, c, siblingStackCache)) continue;
8358
8374
  const read = await readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds);
8359
8375
  findings.push(addedFinding(r, c, read));
8360
8376
  }