cdk-real-drift 0.2.44 → 0.2.46

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
@@ -645,7 +645,7 @@ var QuietIoHost = class extends NonInteractiveIoHost {
645
645
 
646
646
  //#endregion
647
647
  //#region src/synth/synth.ts
648
- const CONCRETE_REGION = /^[a-z]{2}-[a-z]+-\d+$/;
648
+ const CONCRETE_REGION = /^[a-z]{2}(-[a-z]+)+-\d+$/;
649
649
  async function synthApp(app, opts = {}) {
650
650
  const { region, profile, context = {} } = opts;
651
651
  const toolkit = new Toolkit({
@@ -3168,6 +3168,36 @@ function parseCfnTemplate(text) {
3168
3168
  function parseTemplateBody(body) {
3169
3169
  return parseCfnTemplate(body);
3170
3170
  }
3171
+ function partitionForRegion(region) {
3172
+ if (region.startsWith("us-gov-")) return {
3173
+ partition: "aws-us-gov",
3174
+ urlSuffix: "amazonaws.com"
3175
+ };
3176
+ if (region.startsWith("cn-")) return {
3177
+ partition: "aws-cn",
3178
+ urlSuffix: "amazonaws.com.cn"
3179
+ };
3180
+ if (region.startsWith("us-iso-")) return {
3181
+ partition: "aws-iso",
3182
+ urlSuffix: "c2s.ic.gov"
3183
+ };
3184
+ if (region.startsWith("us-isob-")) return {
3185
+ partition: "aws-iso-b",
3186
+ urlSuffix: "sc2s.sgov.gov"
3187
+ };
3188
+ if (region.startsWith("us-isof-")) return {
3189
+ partition: "aws-iso-f",
3190
+ urlSuffix: "csp.hci.ic.gov"
3191
+ };
3192
+ if (region.startsWith("eu-isoe-")) return {
3193
+ partition: "aws-iso-e",
3194
+ urlSuffix: "cloud.adc-e.uk"
3195
+ };
3196
+ return {
3197
+ partition: "aws",
3198
+ urlSuffix: "amazonaws.com"
3199
+ };
3200
+ }
3171
3201
  function buildResolverContext(template, stackParams, physIds, region, accountId, stackName, stackId) {
3172
3202
  const paramDefs = template.Parameters ?? {};
3173
3203
  const isList = (k) => {
@@ -3185,13 +3215,14 @@ function buildResolverContext(template, stackParams, physIds, region, accountId,
3185
3215
  if (res?.Type) typeOf[lid] = res.Type;
3186
3216
  if (res?.Properties) declaredRawProps[lid] = res.Properties;
3187
3217
  }
3218
+ const { partition, urlSuffix } = partitionForRegion(region);
3188
3219
  return {
3189
3220
  params,
3190
3221
  pseudo: {
3191
3222
  "AWS::Region": region,
3192
3223
  "AWS::AccountId": accountId,
3193
- "AWS::Partition": "aws",
3194
- "AWS::URLSuffix": "amazonaws.com",
3224
+ "AWS::Partition": partition,
3225
+ "AWS::URLSuffix": urlSuffix,
3195
3226
  "AWS::StackName": stackName,
3196
3227
  "AWS::StackId": stackId
3197
3228
  },
@@ -8554,7 +8585,7 @@ async function readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds) {
8554
8585
  }
8555
8586
  async function isManagedBySiblingStack(cfn, c, cache) {
8556
8587
  const physicalId = c.identifier;
8557
- if (physicalId.includes("|")) return false;
8588
+ if (physicalId.includes("|")) return "notManaged";
8558
8589
  const cached = cache.get(physicalId);
8559
8590
  if (cached !== void 0) return cached;
8560
8591
  let managed = false;
@@ -8580,11 +8611,16 @@ async function isManagedBySiblingStack(cfn, c, cache) {
8580
8611
  } while (next);
8581
8612
  }
8582
8613
  }
8583
- } catch {
8584
- managed = false;
8614
+ } catch (e) {
8615
+ if (e.name === "ValidationError") {
8616
+ cache.set(physicalId, "notManaged");
8617
+ return "notManaged";
8618
+ }
8619
+ return "unverified";
8585
8620
  }
8586
- cache.set(physicalId, managed);
8587
- return managed;
8621
+ const result = managed ? "managed" : "notManaged";
8622
+ cache.set(physicalId, result);
8623
+ return result;
8588
8624
  }
8589
8625
  const SG_RULE_RESOURCE_SIDE = {
8590
8626
  "AWS::EC2::SecurityGroupIngress": "ingress",
@@ -8720,7 +8756,18 @@ async function gatherFindings(stackName, region, templateOverride, recoveryTempl
8720
8756
  region
8721
8757
  });
8722
8758
  for (const c of children) {
8723
- if (await isManagedBySiblingStack(cfn, c, siblingStackCache)) continue;
8759
+ const sibling = await isManagedBySiblingStack(cfn, c, siblingStackCache);
8760
+ if (sibling === "managed") continue;
8761
+ if (sibling === "unverified") {
8762
+ findings.push({
8763
+ tier: "skipped",
8764
+ logicalId: r.logicalId,
8765
+ resourceType: r.resourceType,
8766
+ path: "",
8767
+ note: `sibling-stack membership unverifiable for ${c.label} (${c.resourceType})`
8768
+ });
8769
+ continue;
8770
+ }
8724
8771
  const read = await readAddedModel(cc, cfn, c, schemas, oaiCanonicalIds);
8725
8772
  findings.push(addedFinding(r, c, read));
8726
8773
  }
@@ -11050,8 +11097,23 @@ function nullHuskRemovalOps(model) {
11050
11097
  walk(model, "");
11051
11098
  return ops;
11052
11099
  }
11100
+ function splitTopLevelDots(dotted) {
11101
+ const out = [];
11102
+ let cur = "";
11103
+ let depth = 0;
11104
+ for (const ch of dotted) {
11105
+ if (ch === "[") depth++;
11106
+ else if (ch === "]") depth = Math.max(0, depth - 1);
11107
+ if (ch === "." && depth === 0) {
11108
+ out.push(cur);
11109
+ cur = "";
11110
+ } else cur += ch;
11111
+ }
11112
+ out.push(cur);
11113
+ return out;
11114
+ }
11053
11115
  function toPointer(dotted) {
11054
- return "/" + dotted.split(".").map((s) => s.replace(/~/g, "~0").replace(/\//g, "~1")).join("/");
11116
+ return "/" + splitTopLevelDots(dotted).map((s) => s.replace(/~/g, "~0").replace(/\//g, "~1")).join("/");
11055
11117
  }
11056
11118
  const DRIFT_TIERS$1 = new Set(["declared", "undeclared"]);
11057
11119
  const SG_REVERT_SIDE = {