cdk-real-drift 0.2.49 → 0.2.50

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
@@ -744,7 +744,12 @@ async function resolveStacks(a) {
744
744
  };
745
745
  const known = () => discovered.map((s) => s.stackName).join(", ") || "none";
746
746
  for (const name of a.stackNames) if (isGlob(name)) {
747
- for (const s of discovered) if (matchesGlob(name, s.stackName)) add(s.stackName, s.region ?? fallbackRegion, s.template);
747
+ let matched = 0;
748
+ for (const s of discovered) if (matchesGlob(name, s.stackName)) {
749
+ matched++;
750
+ add(s.stackName, s.region ?? fallbackRegion, s.template);
751
+ }
752
+ if (matched === 0) throw new Error(`glob "${name}" matched no stacks defined by the CDK app (found: ${known()})`);
748
753
  } else {
749
754
  const hit = discovered.find((s) => s.stackName === name);
750
755
  if (!hit) throw new Error(`stack "${name}" is not defined by the CDK app (found: ${known()})`);
@@ -3258,8 +3263,9 @@ function buildResolverContext(template, stackParams, physIds, region, accountId,
3258
3263
  };
3259
3264
  }
3260
3265
  const exportsCache = /* @__PURE__ */ new Map();
3261
- async function listExports(client, region) {
3262
- const cached = exportsCache.get(region);
3266
+ async function listExports(client, accountId, region) {
3267
+ const cacheKey = `${accountId}:${region}`;
3268
+ const cached = exportsCache.get(cacheKey);
3263
3269
  if (cached) return cached;
3264
3270
  const exports = {};
3265
3271
  let next;
@@ -3268,7 +3274,7 @@ async function listExports(client, region) {
3268
3274
  for (const e of res.Exports ?? []) if (e.Name) exports[e.Name] = e.Value ?? "";
3269
3275
  next = res.NextToken;
3270
3276
  } while (next);
3271
- exportsCache.set(region, exports);
3277
+ exportsCache.set(cacheKey, exports);
3272
3278
  return exports;
3273
3279
  }
3274
3280
  async function listStackResources(client, stackName) {
@@ -3319,7 +3325,12 @@ async function loadDesired(client, stackName, region, templateOverride, recovery
3319
3325
  const ctx = buildResolverContext(template, stackParams, physIds, region, accountId, stackName, stackId);
3320
3326
  const notificationArns = stack?.NotificationARNs ?? [];
3321
3327
  if (notificationArns.length > 0) ctx.params["AWS::NotificationARNs"] = notificationArns;
3322
- if (JSON.stringify(template).includes("Fn::ImportValue")) ctx.exports = await listExports(client, region);
3328
+ if (JSON.stringify(template).includes("Fn::ImportValue")) try {
3329
+ ctx.exports = await listExports(client, accountId, region);
3330
+ } catch (err) {
3331
+ const msg = err instanceof Error ? err.message : String(err);
3332
+ console.error(`warning: ${stackName}: cloudformation:ListExports failed — Fn::ImportValue references will resolve UNRESOLVED (their declared properties are skipped, not compared). Grant cloudformation:ListExports for full coverage. (${msg})`);
3333
+ }
3323
3334
  const resources = [];
3324
3335
  const principalsWithSiblingPolicy = collectPrincipalsWithSiblingPolicies(template.Resources ?? {}, ctx);
3325
3336
  const clustersWithSiblingCapacityProviders = collectClustersWithSiblingCapacityProviders(template.Resources ?? {});
@@ -4877,11 +4888,22 @@ const READ_RETRY = {
4877
4888
  //#endregion
4878
4889
  //#region src/read/kms-aliases.ts
4879
4890
  const cache$1 = /* @__PURE__ */ new Map();
4891
+ /** True when the error is a DEFINITIVE access-denial (cacheable), NOT a transient blip.
4892
+ * Matches an AccessDenied(Exception) / UnauthorizedOperation by name or code, or the AWS
4893
+ * HTTP 403 status. Anything else (throttle, network, 5xx, timeout) is treated as
4894
+ * transient and must NOT be cached. */
4895
+ function isDefinitiveDenial(err) {
4896
+ const e = err;
4897
+ if (!e) return false;
4898
+ const definitive = /^(AccessDenied(Exception)?|UnauthorizedOperation)$/;
4899
+ if (e.name && definitive.test(e.name)) return true;
4900
+ if (e.code && definitive.test(e.code)) return true;
4901
+ return e.$metadata?.httpStatusCode === 403;
4902
+ }
4880
4903
  async function fetchManagedAliasTargets(region) {
4881
4904
  const cached = cache$1.get(region);
4882
4905
  if (cached) return cached;
4883
4906
  const targets = {};
4884
- let result;
4885
4907
  try {
4886
4908
  const c = new KMSClient({
4887
4909
  region,
@@ -4896,18 +4918,27 @@ async function fetchManagedAliasTargets(region) {
4896
4918
  for (const a of r.Aliases ?? []) if (a.AliasName?.startsWith("alias/aws/") && a.TargetKeyId) targets[a.AliasName] = a.TargetKeyId;
4897
4919
  marker = r.Truncated ? r.NextMarker : void 0;
4898
4920
  } while (marker);
4899
- result = {
4921
+ const result = {
4900
4922
  targets,
4901
4923
  denied: false
4902
4924
  };
4903
- } catch {
4904
- result = {
4925
+ cache$1.set(region, result);
4926
+ return result;
4927
+ } catch (e) {
4928
+ if (isDefinitiveDenial(e)) {
4929
+ const result = {
4930
+ targets: {},
4931
+ denied: true
4932
+ };
4933
+ cache$1.set(region, result);
4934
+ return result;
4935
+ }
4936
+ return {
4905
4937
  targets: {},
4906
- denied: true
4938
+ denied: true,
4939
+ transient: true
4907
4940
  };
4908
4941
  }
4909
- cache$1.set(region, result);
4910
- return result;
4911
4942
  }
4912
4943
  /** The one-line warning emitted when ListAliases is denied but the stack declares an
4913
4944
  * AWS-managed alias: the managed-vs-customer key check degrades to shape-only, which
@@ -8408,10 +8439,11 @@ const EMPTY = {
8408
8439
  freeFormMapPaths: []
8409
8440
  };
8410
8441
  async function getSchemaInfo(client, resourceType) {
8411
- const cached = cache.get(resourceType);
8442
+ const cacheKey = `${await client.config.region()}\0${resourceType}`;
8443
+ const cached = cache.get(cacheKey);
8412
8444
  if (cached) return cached;
8413
8445
  const info = await fetch$1(client, resourceType);
8414
- cache.set(resourceType, info);
8446
+ cache.set(cacheKey, info);
8415
8447
  return info;
8416
8448
  }
8417
8449
  const OVERRIDE_READABLE_WRITEONLY = {