@go-to-k/cdkd 0.221.6 → 0.221.8

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.
@@ -3973,8 +3973,9 @@ var TemplateParser = class {
3973
3973
  Object.values(varMap).forEach((v) => this.extractRefsFromValue(v, dependencies));
3974
3974
  }
3975
3975
  }
3976
- if (body !== void 0) for (const match of body.matchAll(/\$\{([^}]+)\}/g)) {
3977
- const placeholder = match[1];
3976
+ if (body !== void 0) for (const match of body.matchAll(/\$\{(!)?([^}]+)\}/g)) {
3977
+ if (match[1] === "!") continue;
3978
+ const placeholder = match[2];
3978
3979
  if (!placeholder) continue;
3979
3980
  const dot = placeholder.indexOf(".");
3980
3981
  const name = dot >= 0 ? placeholder.slice(0, dot) : placeholder;
@@ -5685,8 +5686,13 @@ var IntrinsicFunctionResolver = class {
5685
5686
  async resolveGetAtt(getAtt, context) {
5686
5687
  let logicalId;
5687
5688
  let attributeName;
5688
- if (Array.isArray(getAtt)) [logicalId, attributeName] = getAtt;
5689
- else {
5689
+ if (Array.isArray(getAtt)) {
5690
+ const [rawLogicalId, rawAttributeName] = getAtt;
5691
+ logicalId = rawLogicalId;
5692
+ const resolvedAttributeName = await this.resolveValue(rawAttributeName, context);
5693
+ if (typeof resolvedAttributeName !== "string") throw new Error(`Fn::GetAtt attribute name for ${logicalId} must resolve to a string, got ${typeof resolvedAttributeName}: ${stringifyValue(resolvedAttributeName)}`);
5694
+ attributeName = resolvedAttributeName;
5695
+ } else {
5690
5696
  const parts = getAtt.split(".");
5691
5697
  if (parts.length !== 2) throw new Error(`Invalid Fn::GetAtt format: ${getAtt}`);
5692
5698
  [logicalId, attributeName] = parts;
@@ -5976,10 +5982,24 @@ var IntrinsicFunctionResolver = class {
5976
5982
  for (const [key, val] of Object.entries(variables)) variables[key] = await this.resolveValue(val, context);
5977
5983
  } else template = subArgs;
5978
5984
  const replacements = [];
5979
- const matches = template.matchAll(/\$\{([^}]+)\}/g);
5985
+ const matches = template.matchAll(/\$\{(!)?([^}]*)\}/g);
5980
5986
  for (const match of matches) {
5981
- const varNameStr = match[1];
5982
- if (!varNameStr) continue;
5987
+ const isEscaped = match[1] === "!";
5988
+ const varNameStr = match[2];
5989
+ if (isEscaped) {
5990
+ replacements.push({
5991
+ match: match[0],
5992
+ replacement: `\${${varNameStr ?? ""}}`
5993
+ });
5994
+ continue;
5995
+ }
5996
+ if (!varNameStr) {
5997
+ replacements.push({
5998
+ match: match[0],
5999
+ replacement: match[0]
6000
+ });
6001
+ continue;
6002
+ }
5983
6003
  let replacement;
5984
6004
  if (varNameStr in variables) replacement = String(variables[varNameStr]);
5985
6005
  else {
@@ -6007,8 +6027,11 @@ var IntrinsicFunctionResolver = class {
6007
6027
  replacement
6008
6028
  });
6009
6029
  }
6010
- let result = template;
6011
- for (const { match, replacement } of replacements) result = result.replace(match, replacement);
6030
+ let cursor = 0;
6031
+ let result = template.replace(/\$\{(!)?([^}]*)\}/g, (whole) => {
6032
+ const entry = replacements[cursor++];
6033
+ return entry ? entry.replacement : whole;
6034
+ });
6012
6035
  if (result.includes("{{resolve:")) result = await this.resolveDynamicReferences(result);
6013
6036
  this.logger.debug(`Resolved Fn::Sub: ${result}`);
6014
6037
  return result;
@@ -6383,20 +6406,39 @@ var IntrinsicFunctionResolver = class {
6383
6406
  * Resolve Fn::FindInMap intrinsic function
6384
6407
  *
6385
6408
  * Fn::FindInMap: [MapName, TopLevelKey, SecondLevelKey]
6386
- * Looks up a value in the Mappings section of the template
6409
+ * Fn::FindInMap: [MapName, TopLevelKey, SecondLevelKey, { DefaultValue: <value> }]
6410
+ * Looks up a value in the Mappings section of the template. When the optional
6411
+ * 4th argument supplies a `DefaultValue` and the requested top-level OR
6412
+ * second-level key is absent, CloudFormation returns the DefaultValue instead
6413
+ * of failing; cdkd mirrors that here. Without a DefaultValue the missing-key
6414
+ * cases throw (backward compatible).
6387
6415
  */
6388
6416
  async resolveFindInMap(findInMapArgs, context) {
6389
- const [rawMapName, rawTopLevelKey, rawSecondLevelKey] = findInMapArgs;
6417
+ const [rawMapName, rawTopLevelKey, rawSecondLevelKey, rawOptions] = findInMapArgs;
6390
6418
  const mapName = String(await this.resolveValue(rawMapName, context));
6391
6419
  const topLevelKey = String(await this.resolveValue(rawTopLevelKey, context));
6392
6420
  const secondLevelKey = String(await this.resolveValue(rawSecondLevelKey, context));
6421
+ const hasDefaultValue = typeof rawOptions === "object" && rawOptions !== null && !Array.isArray(rawOptions) && "DefaultValue" in rawOptions;
6422
+ const resolveDefault = () => this.resolveValue(rawOptions["DefaultValue"], context);
6393
6423
  const mappings = context.template.Mappings;
6394
- if (!mappings) throw new Error(`Fn::FindInMap: no Mappings section found in template`);
6395
- const map = mappings[mapName];
6396
- if (!map) throw new Error(`Fn::FindInMap: mapping '${mapName}' not found in Mappings section`);
6424
+ const map = mappings?.[mapName];
6425
+ if (!mappings) {
6426
+ if (hasDefaultValue) return await resolveDefault();
6427
+ throw new Error(`Fn::FindInMap: no Mappings section found in template`);
6428
+ }
6429
+ if (!map) {
6430
+ if (hasDefaultValue) return await resolveDefault();
6431
+ throw new Error(`Fn::FindInMap: mapping '${mapName}' not found in Mappings section`);
6432
+ }
6397
6433
  const topLevel = map[topLevelKey];
6398
- if (!topLevel || typeof topLevel !== "object") throw new Error(`Fn::FindInMap: top-level key '${topLevelKey}' not found in mapping '${mapName}'`);
6399
- if (!(secondLevelKey in topLevel)) throw new Error(`Fn::FindInMap: second-level key '${secondLevelKey}' not found in mapping '${mapName}' -> '${topLevelKey}'`);
6434
+ if (!topLevel || typeof topLevel !== "object") {
6435
+ if (hasDefaultValue) return await resolveDefault();
6436
+ throw new Error(`Fn::FindInMap: top-level key '${topLevelKey}' not found in mapping '${mapName}'`);
6437
+ }
6438
+ if (!(secondLevelKey in topLevel)) {
6439
+ if (hasDefaultValue) return await resolveDefault();
6440
+ throw new Error(`Fn::FindInMap: second-level key '${secondLevelKey}' not found in mapping '${mapName}' -> '${topLevelKey}'`);
6441
+ }
6400
6442
  const result = topLevel[secondLevelKey];
6401
6443
  this.logger.debug(`Resolved Fn::FindInMap: ${mapName}.${topLevelKey}.${secondLevelKey} -> ${JSON.stringify(result)}`);
6402
6444
  return result;
@@ -11428,6 +11470,8 @@ const RETRYABLE_ERROR_MESSAGE_PATTERNS = [
11428
11470
  "Cannot access stream",
11429
11471
  "Please ensure the role can perform",
11430
11472
  "KMS key is invalid for CreateGrant",
11473
+ "Policy contains a statement with one or more invalid principals",
11474
+ "Invalid IAM Instance Profile",
11431
11475
  "Could not deliver test message",
11432
11476
  "wait 60 seconds",
11433
11477
  "concurrent update operation",
@@ -12890,4 +12934,4 @@ var DeployEngine = class {
12890
12934
 
12891
12935
  //#endregion
12892
12936
  export { clearBucketRegionCache as $, AssetPublisher as A, getLegacyStateBucketName as B, DiffCalculator as C, S3StateBackend as D, LockManager as E, getDockerCmd as F, resolveStateBucketWithDefaultAndSource as G, resolveCaptureObservedState as H, runDockerForeground as I, CFN_TEMPLATE_URL_LIMIT as J, warnDeprecatedNoPrefixCliFlag as K, runDockerStreaming as L, WorkGraph as M, buildDockerImage as N, rebuildClientForBucketRegion as O, formatDockerLoginError as P, AssemblyReader as Q, Synthesizer as R, applyRoleArnIfSet as S, TemplateParser as T, resolveSkipPrefix as U, resolveApp as V, resolveStateBucketWithDefault as W, findLargeInlineResources as X, MIGRATE_TMP_PREFIX as Y, uploadCfnTemplate as Z, collectInlinePolicyNamesManagedBySiblings as _, withRetry as a, CloudControlProvider as b, extractDeploymentEventError as c, cyan as d, resolveBucketRegion as et, gray as f, IAMRoleProvider as g, yellow as h, withResourceDeadline as i, stringifyValue as j, shouldRetainResource as k, formatResourceLine as l, red as m, DEFAULT_RESOURCE_WARN_AFTER_MS as n, isRetryableTransientError as o, green as p, CFN_TEMPLATE_BODY_LIMIT as q, DeployEngine as r, IMPLICIT_DELETE_DEPENDENCIES as s, DEFAULT_RESOURCE_TIMEOUT_MS as t, bold as u, ProviderRegistry as v, DagBuilder as w, IntrinsicFunctionResolver as x, findActionableSilentDrops as y, getDefaultStateBucketName as z };
12893
- //# sourceMappingURL=deploy-engine-DlXVqVTW.js.map
12937
+ //# sourceMappingURL=deploy-engine-DCkhw7i7.js.map