@cdkd/cli 0.371.1 → 0.373.0

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.
Files changed (69) hide show
  1. package/dist/{ambient-client-defaults-Cq58skpK.js → ambient-client-defaults-1yRnA0Re.js} +3 -3
  2. package/dist/{ambient-client-defaults-Cq58skpK.js.map → ambient-client-defaults-1yRnA0Re.js.map} +1 -1
  3. package/dist/{asg-provider-B3ngG-X4.js → asg-provider-3uPCjYQK.js} +8 -8
  4. package/dist/{asg-provider-B3ngG-X4.js.map → asg-provider-3uPCjYQK.js.map} +1 -1
  5. package/dist/cli.js +3 -3
  6. package/dist/{created-resource-sink-Bzk9hJNq.js → created-resource-sink-CBOr1ShX.js} +4 -4
  7. package/dist/{created-resource-sink-Bzk9hJNq.js.map → created-resource-sink-CBOr1ShX.js.map} +1 -1
  8. package/dist/{custom-resource-runtime-CLHhYoEe.js → custom-resource-runtime-DURpNFOa.js} +6 -6
  9. package/dist/{custom-resource-runtime-CLHhYoEe.js.map → custom-resource-runtime-DURpNFOa.js.map} +1 -1
  10. package/dist/{db-associated-roles-CYA2C3yZ.js → db-associated-roles-BbvtfXqW.js} +2 -2
  11. package/dist/{db-associated-roles-CYA2C3yZ.js.map → db-associated-roles-BbvtfXqW.js.map} +1 -1
  12. package/dist/{delete-started-D9FEXTba.js → delete-started-yz9plykR.js} +4 -4
  13. package/dist/{delete-started-D9FEXTba.js.map → delete-started-yz9plykR.js.map} +1 -1
  14. package/dist/{deploy-engine-DvPDae31.js → deploy-engine-C12Ygjb-.js} +4553 -777
  15. package/dist/deploy-engine-C12Ygjb-.js.map +1 -0
  16. package/dist/{ec2-termination-protection-C19A5IH9.js → ec2-termination-protection-UZAZ2Hzv.js} +3 -3
  17. package/dist/{ec2-termination-protection-C19A5IH9.js.map → ec2-termination-protection-UZAZ2Hzv.js.map} +1 -1
  18. package/dist/{ecr-uri-BW6V_9R5.js → ecr-uri-C74u9FtL.js} +2 -2
  19. package/dist/{ecr-uri-BW6V_9R5.js.map → ecr-uri-C74u9FtL.js.map} +1 -1
  20. package/dist/{emr-cluster-provider-DVljF3YH.js → emr-cluster-provider-2ezuxbz3.js} +10 -10
  21. package/dist/{emr-cluster-provider-DVljF3YH.js.map → emr-cluster-provider-2ezuxbz3.js.map} +1 -1
  22. package/dist/{expected-bucket-owner-DMq5H0Zm.js → expected-bucket-owner-0yx_Q4Hl.js} +2 -2
  23. package/dist/{expected-bucket-owner-DMq5H0Zm.js.map → expected-bucket-owner-0yx_Q4Hl.js.map} +1 -1
  24. package/dist/{iam-role-provider-B8c2g5fS.js → iam-role-provider-CZtZQJRp.js} +12 -12
  25. package/dist/{iam-role-provider-B8c2g5fS.js.map → iam-role-provider-CZtZQJRp.js.map} +1 -1
  26. package/dist/{identity-read-denied-Cl8km1o3.js → identity-read-denied-DBsqwW85.js} +5 -5
  27. package/dist/{identity-read-denied-Cl8km1o3.js.map → identity-read-denied-DBsqwW85.js.map} +1 -1
  28. package/dist/{image-plan-Cg5bLNvP.js → image-plan-DW_fg6mx.js} +20 -12
  29. package/dist/image-plan-DW_fg6mx.js.map +1 -0
  30. package/dist/index.d.ts +29 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -5
  33. package/dist/{logger-BUi1Imxa.js → logger-JtU7m4ph.js} +2 -2
  34. package/dist/{logger-BUi1Imxa.js.map → logger-JtU7m4ph.js.map} +1 -1
  35. package/dist/{neptune-provider-Ddse7yYJ.js → neptune-provider-ClT-eveS.js} +9 -9
  36. package/dist/{neptune-provider-Ddse7yYJ.js.map → neptune-provider-ClT-eveS.js.map} +1 -1
  37. package/dist/{program-bUaiwzJ2.js → program-BPrn1MhZ.js} +508 -790
  38. package/dist/program-BPrn1MhZ.js.map +1 -0
  39. package/dist/{provider-classes-AI1PLFRf.js → provider-classes-Bi3D5zDS.js} +22 -22
  40. package/dist/{provider-classes-AI1PLFRf.js.map → provider-classes-Bi3D5zDS.js.map} +1 -1
  41. package/dist/{rds-provider-6Cj8pik8.js → rds-provider-D610vnfB.js} +13 -13
  42. package/dist/{rds-provider-6Cj8pik8.js.map → rds-provider-D610vnfB.js.map} +1 -1
  43. package/dist/{read-replica-DWbYq3Fh.js → read-replica-Br2tFu0d.js} +3 -3
  44. package/dist/{read-replica-DWbYq3Fh.js.map → read-replica-Br2tFu0d.js.map} +1 -1
  45. package/dist/{redacted-delete-address-C1M-bYXm.js → redacted-delete-address-DVgNoeo4.js} +4 -4
  46. package/dist/{redacted-delete-address-C1M-bYXm.js.map → redacted-delete-address-DVgNoeo4.js.map} +1 -1
  47. package/dist/{replacement-rules-BimJi0H1.js → replacement-rules-BoZMVFdK.js} +2166 -1663
  48. package/dist/replacement-rules-BoZMVFdK.js.map +1 -0
  49. package/dist/{resource-deadline-Cj-4PzvY.js → resource-deadline-BkQ9mJAk.js} +2 -2
  50. package/dist/{resource-deadline-Cj-4PzvY.js.map → resource-deadline-BkQ9mJAk.js.map} +1 -1
  51. package/dist/{restore-source-guard-CP2cxnnh.js → restore-source-guard-BkS5tGr5.js} +4 -4
  52. package/dist/{restore-source-guard-CP2cxnnh.js.map → restore-source-guard-BkS5tGr5.js.map} +1 -1
  53. package/dist/{run-cli-C0ZXPvze.js → run-cli-Ds9QnqnH.js} +2 -2
  54. package/dist/{run-cli-C0ZXPvze.js.map → run-cli-Ds9QnqnH.js.map} +1 -1
  55. package/dist/{secret-reference-immutable-BLsAuIkM.js → secret-reference-immutable-BC4abPuQ.js} +20 -11
  56. package/dist/secret-reference-immutable-BC4abPuQ.js.map +1 -0
  57. package/dist/{settle-own-write-members-BJ1rf1Yt.js → settle-own-write-members-D6wzEt7f.js} +13 -771
  58. package/dist/settle-own-write-members-D6wzEt7f.js.map +1 -0
  59. package/dist/{tag-list-CSQWFQbX.js → tag-list-UEcqQLzY.js} +4 -4
  60. package/dist/{tag-list-CSQWFQbX.js.map → tag-list-UEcqQLzY.js.map} +1 -1
  61. package/dist/{version-CQenoJzP.js → version-Dn0kzidt.js} +2 -2
  62. package/dist/{version-CQenoJzP.js.map → version-Dn0kzidt.js.map} +1 -1
  63. package/package.json +1 -1
  64. package/dist/deploy-engine-DvPDae31.js.map +0 -1
  65. package/dist/image-plan-Cg5bLNvP.js.map +0 -1
  66. package/dist/program-bUaiwzJ2.js.map +0 -1
  67. package/dist/replacement-rules-BimJi0H1.js.map +0 -1
  68. package/dist/secret-reference-immutable-BLsAuIkM.js.map +0 -1
  69. package/dist/settle-own-write-members-BJ1rf1Yt.js.map +0 -1
@@ -1,17 +1,14 @@
1
- import { A as displayStackName, C as STACK_REF_MAX_CODE_POINTS, D as displayAwsMessage, O as displayIdent, P as safeMsg, _ as shellQuote, k as displaySafe, m as proseQuoted, o as cdkdRemedy, p as plainOrDescribed, r as SHELL_ACTIVE, w as UNRENDERABLE } from "./version-CQenoJzP.js";
2
- import { _ as currentLogLineMasker, l as describeAwsErrorDiagnostics, m as verboseAwareText, n as getLogger, p as safeStringify$1, r as isStdoutReservedForPayload, u as describeAwsFailure } from "./logger-BUi1Imxa.js";
3
- import { $ as AssetError, G as markRedactedCause, ct as SynthesisError, d as MacroExpansionError, et as CdkdError, it as LockError, k as escapeRegExp, lt as isSoftAbort, nt as DeploymentNotApprovedError, p as DependencyError, st as StateError, t as ambientClientDefaults } from "./ambient-client-defaults-Cq58skpK.js";
1
+ import { A as displayStackName, C as STACK_REF_MAX_CODE_POINTS, D as displayAwsMessage, O as displayIdent, P as safeMsg, _ as shellQuote, k as displaySafe, m as proseQuoted, o as cdkdRemedy, p as plainOrDescribed, r as SHELL_ACTIVE, w as UNRENDERABLE } from "./version-Dn0kzidt.js";
2
+ import { _ as currentLogLineMasker, l as describeAwsErrorDiagnostics, m as verboseAwareText, n as getLogger, p as safeStringify$1, r as isStdoutReservedForPayload, u as describeAwsFailure } from "./logger-JtU7m4ph.js";
3
+ import { $ as AssetError, G as markRedactedCause, ct as SynthesisError, d as MacroExpansionError, et as CdkdError, it as LockError, k as escapeRegExp, lt as isSoftAbort, nt as DeploymentNotApprovedError, p as DependencyError, st as StateError, t as ambientClientDefaults } from "./ambient-client-defaults-1yRnA0Re.js";
4
4
  import { n as awsClientDefaults, r as awsEndpointOverrideActive } from "./aws-client-defaults-DAebi99J.js";
5
5
  import { l as s3ClientDefaults } from "./aws-clients-DOkPjjAW.js";
6
- import { Ad as createLazyAssetModeContext, Bc as containsIntrinsic, Bd as isCfnTemplateAssetPath, Ec as recordedProvenanceOf, Ed as rememberSynthesizedStacks, Fd as redirectDockerAsset, Gc as isLegacyHandleId, Gu as providerReplacementReason, Hc as replacementSidesForLog, Hd as resolveFileAssetSourcePath, Id as redirectFileAsset, Lu as withoutAcceptedSdkUnwiredProperties, Md as isDefaultBootstrapBucketName, Nd as isDefaultBootstrapRepoName, Oc as referenceProvenanceOf, Pd as loadPublishableAssetManifest, Qu as isKnownTokenFreeState, Rc as namesRecreatedParent, Rl as refuseMalformedResourceEntriesForDeploy, Sc as promoteInPlaceAttributeDependents, Sd as ssmResolvedValueType, Uc as siblingsOf, Ud as warnAbsoluteAssetPath, Uo as settleDeclaredMember, Uu as dropSupersededProviderReplacements, Vc as markNewValueKnownAfterDeploy, Vd as parseAssetManifestBody, Vo as policyDocumentMatchesDeclared, Wd as warnWholeAssemblyAsSource, Yu as TemplateParser, _d as listNestedTemplateRows, _f as resolveBucketRegion, bd as SSM_PARAMETER_VALUE_PREFIX, df as describeFileReadFailure, dl as inputFingerprinter, ff as displayAssemblyPath, hf as resolveAssemblyPath, if as defineOwnKey, jd as flattenAssetPlaceholders, kc as referenceTokensIn, lf as absoluteAssemblyPathEscape, mc as AWS_NO_VALUE, md as missingStateBucketRemedy, mf as renderAssemblyPathEscape, nd as rebuildClientForBucketRegion, nf as getCdkdAssetBucketName, pd as stringifyValue, pf as namesTheSameDirectory, pl as movedMaskedProperties, qc as isPlainReferenceTo, ql as refuseMalformedResourceProperties, rf as getCdkdContainerRepoName, sf as nullPrototypeRecord, uf as assemblyPathEscape, ul as tryGetTopLevelWriteOnlyProperties, wd as purgeNoncurrentKeyVersions, xc as extractGetAttRefs, xd as isListParameterType, zc as INTRINSIC_KEYS, zu as withoutUnwrittenSdkUnwiredProperties } from "./deploy-engine-DvPDae31.js";
7
- import { D as parseFailureDebugDetail, E as jsonParseFailureStandIn, T as describeJsonParseFailure, a as getCreateOnlyPropertyPaths, i as createOnlyChangeRequiresReplacement, k as utf8ByteLength } from "./secret-reference-immutable-BLsAuIkM.js";
6
+ import { $d as loadPublishableAssetManifest, Af as describeFileReadFailure, Cf as defineOwnKey, Ef as nullPrototypeRecord, Fd as SSM_PARAMETER_VALUE_PREFIX, Gd as rememberSynthesizedStacks, Id as isListParameterType, Ld as ssmResolvedValueType, Md as listNestedTemplateRows, Mf as namesTheSameDirectory, Nf as renderAssemblyPathEscape, Od as stringifyValue, Of as absoluteAssemblyPathEscape, Pf as resolveAssemblyPath, Qd as isDefaultBootstrapRepoName, Rd as CFN_TEMPLATE_BODY_LIMIT, Sf as getCdkdContainerRepoName, Ud as purgeNoncurrentKeyVersions, Vd as uploadCfnTemplate, Xd as flattenAssetPlaceholders, Yd as createLazyAssetModeContext, Zd as isDefaultBootstrapBucketName, _d as rebuildClientForBucketRegion, _s as policyDocumentMatchesDeclared, af as isCfnTemplateAssetPath, cf as warnAbsoluteAssetPath, dd as TemplateParser, ef as redirectDockerAsset, jf as displayAssemblyPath, kd as missingStateBucketRemedy, kf as assemblyPathEscape, lf as warnWholeAssemblyAsSource, of as parseAssetManifestBody, sf as resolveFileAssetSourcePath, tf as redirectFileAsset, xf as getCdkdAssetBucketName, ys as settleDeclaredMember, zd as CFN_TEMPLATE_URL_LIMIT } from "./deploy-engine-C12Ygjb-.js";
7
+ import { D as parseFailureDebugDetail, E as jsonParseFailureStandIn, T as describeJsonParseFailure, k as utf8ByteLength } from "./secret-reference-immutable-BC4abPuQ.js";
8
8
  import { r as derivePartitionAndUrlSuffix } from "./aws-partition-DA0r2sr-.js";
9
- import { Lt as maskerOrIdentity, Qt as buildForceUnlockCommand, Zt as UNREPRODUCIBLE_LOCK_CLAUSE, dn as withPasteableAwsProfile, fn as injectiveKey, nn as formatLockOperation, rn as formatLockOwner, tn as formatLockExpiry } from "./created-resource-sink-Bzk9hJNq.js";
10
- import { t as expectedOwnerParam } from "./expected-bucket-owner-DMq5H0Zm.js";
11
- import { _t as acceptedCreateOnlyDropsOf } from "./delete-started-D9FEXTba.js";
12
- import { Cn as splitGetAttStringForm, t as ReplacementRulesRegistry } from "./replacement-rules-BimJi0H1.js";
13
- import { S as willReplaceGroup, v as REPLACEMENT_TRIGGER_PROPERTIES, y as changedTriggers } from "./ec2-termination-protection-C19A5IH9.js";
14
- import { S as unsettledPropertiesOf } from "./restore-source-guard-CP2cxnnh.js";
9
+ import { Qt as buildForceUnlockCommand, Zt as UNREPRODUCIBLE_LOCK_CLAUSE, dn as withPasteableAwsProfile, fn as injectiveKey, nn as formatLockOperation, rn as formatLockOwner, tn as formatLockExpiry } from "./created-resource-sink-CBOr1ShX.js";
10
+ import { t as expectedOwnerParam } from "./expected-bucket-owner-0yx_Q4Hl.js";
11
+ import { An as splitGetAttStringForm } from "./replacement-rules-BoZMVFdK.js";
15
12
  import { randomBytes, randomUUID } from "node:crypto";
16
13
  import { AbortMultipartUploadCommand, DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, NoSuchKey, PutObjectCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3";
17
14
  import { CloudControlClient, GetResourceCommand, ListResourcesCommand } from "@aws-sdk/client-cloudcontrol";
@@ -1060,7 +1057,7 @@ var CcApiContextProvider = class {
1060
1057
  if (exactIdentifier && propertyMatch) throw new Error("CC API context provider: specify either exactIdentifier or propertyMatch, but not both");
1061
1058
  if (!exactIdentifier && !propertyMatch) throw new Error("CC API context provider: neither exactIdentifier nor propertyMatch is specified");
1062
1059
  if (ignoreErrorOnMissingContext && dummyValue === void 0) throw new Error("CC API context provider: if ignoreErrorOnMissingContext is set, a dummyValue must be supplied");
1063
- if (dummyValue !== void 0 && (!Array.isArray(dummyValue) || !dummyValue.every((v) => isPlainObject$1(v)))) throw new Error("CC API context provider: dummyValue must be an array of objects");
1060
+ if (dummyValue !== void 0 && (!Array.isArray(dummyValue) || !dummyValue.every((v) => isPlainObject(v)))) throw new Error("CC API context provider: dummyValue must be an array of objects");
1064
1061
  this.logger.debug(`CC API lookup: ${typeName}${exactIdentifier ? ` (id: ${exactIdentifier})` : ""} (region: ${region})`);
1065
1062
  const client = new CloudControlClient({
1066
1063
  ...ambientClientDefaults(),
@@ -1138,7 +1135,7 @@ var CcApiContextProvider = class {
1138
1135
  return result;
1139
1136
  }
1140
1137
  };
1141
- function isPlainObject$1(value) {
1138
+ function isPlainObject(value) {
1142
1139
  return typeof value === "object" && value !== null && !Array.isArray(value);
1143
1140
  }
1144
1141
  function expectedMatchCountText(expectedMatchCount) {
@@ -1484,93 +1481,6 @@ function collectFnTransformNames(value, seen, out) {
1484
1481
  }
1485
1482
  }
1486
1483
 
1487
- // src/cli/upload-cfn-template.ts
1488
- const CFN_TEMPLATE_BODY_LIMIT = 51200;
1489
- const CFN_TEMPLATE_URL_LIMIT = 1048576;
1490
- const MIGRATE_TMP_PREFIX = "cdkd-migrate-tmp";
1491
- async function uploadCfnTemplate(args) {
1492
- const { bucket, body, stackName, format, s3ClientOpts } = args;
1493
- const region = await resolveBucketRegion(bucket, {
1494
- ...s3ClientOpts?.profile && { profile: s3ClientOpts.profile },
1495
- ...s3ClientOpts?.credentials && { credentials: s3ClientOpts.credentials }
1496
- });
1497
- const s3 = new S3Client({
1498
- ...awsClientDefaults({ profile: s3ClientOpts?.profile }),
1499
- ...s3ClientDefaults(),
1500
- region,
1501
- ...s3ClientOpts?.profile && { profile: s3ClientOpts.profile },
1502
- ...s3ClientOpts?.credentials && { credentials: s3ClientOpts.credentials }
1503
- });
1504
- const ext = format === "yaml" ? "yaml" : "json";
1505
- const contentType = format === "yaml" ? "application/x-yaml" : "application/json";
1506
- const key = `${MIGRATE_TMP_PREFIX}/${stackName}/${Date.now()}.${ext}`;
1507
- try {
1508
- await s3.send(new PutObjectCommand({
1509
- ...await expectedOwnerParam(s3),
1510
- Bucket: bucket,
1511
- Key: key,
1512
- Body: body,
1513
- ContentType: contentType
1514
- }));
1515
- } catch (err) {
1516
- s3.destroy();
1517
- throw err;
1518
- }
1519
- const { urlSuffix } = derivePartitionAndUrlSuffix(region);
1520
- const url = `https://${bucket}.s3.${region}.${urlSuffix}/${key}`;
1521
- const cleanup = async () => {
1522
- try {
1523
- await s3.send(new DeleteObjectCommand({
1524
- Bucket: bucket,
1525
- Key: key,
1526
- ...await expectedOwnerParam(s3)
1527
- }));
1528
- } finally {
1529
- try {
1530
- await purgeNoncurrentKeyVersions(s3, bucket, [key], {
1531
- requestFields: await expectedOwnerParam(s3),
1532
- logger: getLogger(),
1533
- objectDescription: "the transient CloudFormation template body uploaded for this command"
1534
- });
1535
- } catch (purgeError) {
1536
- getLogger().warn(`Could not purge noncurrent versions of the transient template s3://${bucket}/${key}; its previous versions survive and remain readable via GetObject with a VersionId. Grant s3:ListBucketVersions and s3:DeleteObjectVersion on the state bucket, or purge the key by hand. Underlying error: ${describeAwsFailure(purgeError).detail}`);
1537
- } finally {
1538
- s3.destroy();
1539
- }
1540
- }
1541
- };
1542
- return {
1543
- url,
1544
- cleanup
1545
- };
1546
- }
1547
- const LARGE_INLINE_RESOURCE_THRESHOLD = 4096;
1548
- function findLargeInlineResources(template, threshold = LARGE_INLINE_RESOURCE_THRESHOLD) {
1549
- const result = [];
1550
- const resources = template["Resources"];
1551
- if (!resources || typeof resources !== "object" || Array.isArray(resources)) return result;
1552
- for (const [logicalId, resource] of Object.entries(resources)) {
1553
- if (!resource || typeof resource !== "object" || Array.isArray(resource)) continue;
1554
- const r = resource;
1555
- const resourceType = typeof r["Type"] === "string" ? r["Type"] : "<unknown>";
1556
- const properties = r["Properties"];
1557
- if (properties === void 0 || properties === null) continue;
1558
- let approxBytes;
1559
- try {
1560
- approxBytes = JSON.stringify(properties).length;
1561
- } catch {
1562
- continue;
1563
- }
1564
- if (approxBytes >= threshold) result.push({
1565
- logicalId,
1566
- resourceType,
1567
- approxBytes
1568
- });
1569
- }
1570
- result.sort((a, b) => b.approxBytes - a.approxBytes);
1571
- return result;
1572
- }
1573
-
1574
1484
  // src/synthesis/macro-expander.ts
1575
1485
  function displaySafeTransforms(names) {
1576
1486
  return names.map((name) => displaySafe(name)).join(", ");
@@ -2025,7 +1935,7 @@ async function resolveStateBucketWithDefaultAndSource(cliBucket, region, legacyF
2025
1935
  const { GetCallerIdentityCommand } = await import("@aws-sdk/client-sts");
2026
1936
  const { S3Client, HeadBucketCommand, ListObjectsV2Command } = await import("@aws-sdk/client-s3");
2027
1937
  const { getAwsClients } = await import("./aws-clients-DOkPjjAW.js").then((n) => n.n);
2028
- const { expectedOwnerParam, recordResolvedAccountId } = await import("./expected-bucket-owner-DMq5H0Zm.js").then((n) => n.n);
1938
+ const { expectedOwnerParam, recordResolvedAccountId } = await import("./expected-bucket-owner-0yx_Q4Hl.js").then((n) => n.n);
2029
1939
  const probeDeps = {
2030
1940
  HeadBucketCommand,
2031
1941
  ListObjectsV2Command,
@@ -4839,674 +4749,6 @@ var DagBuilder = class {
4839
4749
  }
4840
4750
  };
4841
4751
 
4842
- // src/analyzer/diff-calculator/update-policy-replacement.ts
4843
- function markUpdatePolicyReplacements(changes, desiredTemplate) {
4844
- for (const [logicalId, change] of changes) {
4845
- if (change.changeType !== "UPDATE") continue;
4846
- if (change.resourceType !== "AWS::AutoScaling::AutoScalingGroup") continue;
4847
- const updatePolicy = desiredTemplate.Resources[logicalId]?.UpdatePolicy;
4848
- if (typeof updatePolicy !== "object" || updatePolicy === null) continue;
4849
- if (!willReplaceGroup(updatePolicy)) continue;
4850
- for (const pc of change.propertyChanges ?? []) {
4851
- if (pc.noEchoPromoted === true) continue;
4852
- const top = pc.path.split(/[.[]/)[0] ?? pc.path;
4853
- if (!REPLACEMENT_TRIGGER_PROPERTIES.includes(top)) continue;
4854
- if (pc.inPlacePropagated !== true && pc.replacementPropagated !== true && changedTriggers([top], change.desiredProperties ?? {}, change.currentProperties ?? {}).length === 0) continue;
4855
- pc.requiresReplacement = true;
4856
- pc.updatePolicyReplacement = true;
4857
- }
4858
- }
4859
- }
4860
-
4861
- // src/analyzer/diff-calculator/legacy-handle-heal.ts
4862
- const LEGACY_HANDLE_HEAL_REASON = "issues a signal URL in place of the placeholder id an earlier cdkd recorded";
4863
- function markLegacyHandleHeals(changes, currentResources, desiredTemplate, extractReferences) {
4864
- const legacy = /* @__PURE__ */ new Set();
4865
- for (const [logicalId, record] of Object.entries(currentResources)) if (record.resourceType === "AWS::CloudFormation::WaitConditionHandle" && isLegacyHandleId(record.physicalId) && desiredTemplate.Resources[logicalId]?.Type === "AWS::CloudFormation::WaitConditionHandle") legacy.add(logicalId);
4866
- if (legacy.size === 0) return [];
4867
- const waitedOn = /* @__PURE__ */ new Set();
4868
- for (const resource of Object.values(desiredTemplate.Resources)) {
4869
- if (resource.Type !== "AWS::CloudFormation::WaitCondition") continue;
4870
- for (const ref of extractReferences(resource.Properties?.["Handle"])) if (legacy.has(ref)) waitedOn.add(ref);
4871
- }
4872
- const healed = [];
4873
- for (const handleId of waitedOn) {
4874
- const change = changes.get(handleId);
4875
- if (change === void 0) continue;
4876
- if (change.changeType !== "NO_CHANGE" && change.changeType !== "UPDATE") continue;
4877
- change.changeType = "UPDATE";
4878
- change.propertyChanges ??= [];
4879
- change.providerReplacement = LEGACY_HANDLE_HEAL_REASON;
4880
- healed.push(handleId);
4881
- }
4882
- return healed;
4883
- }
4884
-
4885
- // src/analyzer/diff-calculator/calculate-diff.ts
4886
- async function calculateDiff(currentState, desiredTemplate, resolveFn, canonicalizeProperties, allowedUnsupportedProperties, freshParameters, maskForLog, recreateTargets, maskedInputs, refusalRecovery, noEchoCompare, readProvenance, forcedNestedChildRuns, updatePolicy) {
4887
- const changes = /* @__PURE__ */ new Map();
4888
- refuseMalformedResourceEntriesForDeploy(currentState, void 0, void 0, refusalRecovery);
4889
- refuseMalformedResourceProperties(currentState, void 0, void 0, refusalRecovery);
4890
- const currentResources = currentState.resources;
4891
- const desiredResources = desiredTemplate.Resources;
4892
- this.logger.debug("Calculating diff...");
4893
- this.logger.debug(`Current resources: ${Object.keys(currentResources).length}`);
4894
- this.logger.debug(`Desired resources: ${Object.keys(desiredResources).length}`);
4895
- const processedLogicalIds = /* @__PURE__ */ new Set();
4896
- const rawGetAttRefs = /* @__PURE__ */ new Map();
4897
- for (const [logicalId, desiredResource] of Object.entries(desiredResources)) {
4898
- if (desiredResource.Type === "AWS::CDK::Metadata") continue;
4899
- const perProp = /* @__PURE__ */ new Map();
4900
- for (const [propKey, propValue] of Object.entries(desiredResource.Properties ?? {})) {
4901
- const refs = DiffCalculator.extractGetAttRefs(propValue);
4902
- if (refs.size > 0) perProp.set(propKey, refs);
4903
- }
4904
- if (perProp.size > 0) rawGetAttRefs.set(logicalId, perProp);
4905
- }
4906
- for (const [logicalId, desiredResource] of Object.entries(desiredResources)) {
4907
- if (desiredResource.Type === "AWS::CDK::Metadata") {
4908
- this.logger.debug(`Skipping metadata resource: ${logicalId}`);
4909
- processedLogicalIds.add(logicalId);
4910
- continue;
4911
- }
4912
- processedLogicalIds.add(logicalId);
4913
- const currentResource = currentResources[logicalId];
4914
- if (!currentResource) {
4915
- changes.set(logicalId, {
4916
- logicalId,
4917
- changeType: "CREATE",
4918
- resourceType: desiredResource.Type,
4919
- desiredProperties: desiredResource.Properties || {}
4920
- });
4921
- this.logger.debug(`CREATE: ${logicalId} (${desiredResource.Type})`);
4922
- } else if (currentResource.resourceType !== desiredResource.Type) {
4923
- const propertyChanges = [{
4924
- path: "Type",
4925
- oldValue: currentResource.resourceType,
4926
- newValue: desiredResource.Type,
4927
- requiresReplacement: true
4928
- }];
4929
- changes.set(logicalId, {
4930
- logicalId,
4931
- changeType: "UPDATE",
4932
- resourceType: desiredResource.Type,
4933
- currentProperties: currentResource.properties,
4934
- desiredProperties: desiredResource.Properties || {},
4935
- propertyChanges
4936
- });
4937
- this.logger.debug(`UPDATE (Type change): ${logicalId} (from ${currentResource.resourceType} to ${desiredResource.Type})`);
4938
- } else {
4939
- const rawDesiredProps = desiredResource.Properties || {};
4940
- const resolvedDesiredProps = resolveFn ? await this.resolveBestEffort(rawDesiredProps, resolveFn) : rawDesiredProps;
4941
- const sdkRouted = currentResource.provisionedBy !== "cc-api";
4942
- const desiredAfterDrops = sdkRouted && allowedUnsupportedProperties ? withoutAcceptedSdkUnwiredProperties(desiredResource.Type, resolvedDesiredProps, allowedUnsupportedProperties, currentResource.properties) : resolvedDesiredProps;
4943
- const currentAfterDrops = sdkRouted ? withoutUnwrittenSdkUnwiredProperties(desiredResource.Type, currentResource.properties, resolvedDesiredProps, allowedUnsupportedProperties ?? /* @__PURE__ */ new Set(), acceptedCreateOnlyDropsOf(currentResource)) : currentResource.properties;
4944
- const desiredPropsForCompare = canonicalizeProperties ? canonicalizeProperties(desiredResource.Type, desiredAfterDrops) : desiredAfterDrops;
4945
- const currentPropsForCompare = canonicalizeProperties && sdkRouted ? canonicalizeProperties(desiredResource.Type, currentAfterDrops) : currentAfterDrops;
4946
- const droppedKeys = canonicalizeProperties ? Object.keys(desiredAfterDrops).filter((key) => !Object.hasOwn(desiredPropsForCompare, key)) : [];
4947
- if (droppedKeys.length > 0) this.logger.warn(`${logicalId} (${desiredResource.Type}): part of the declared properties cannot be sent as declared and is ignored when comparing against deployed state — the provider narrows them (${droppedKeys.join(", ")}). Fix the template to declare only what the resource supports; until then changes to the ignored keys have no effect.`);
4948
- else if (canonicalizeProperties && !this.valuesEqual(desiredPropsForCompare, desiredAfterDrops)) this.logger.debug(`${logicalId} (${desiredResource.Type}): the provider normalizes part of the declared properties before sending them; the comparison uses the normalized form. Nothing is dropped.`);
4949
- const noEchoCompared = noEchoCompare?.({
4950
- logicalId,
4951
- resourceType: desiredResource.Type,
4952
- templateProperties: rawDesiredProps,
4953
- desired: desiredPropsForCompare,
4954
- current: currentPropsForCompare
4955
- });
4956
- const desiredCompared = noEchoCompared?.desired ?? desiredPropsForCompare;
4957
- const currentCompared = noEchoCompared?.current ?? currentPropsForCompare;
4958
- const propertyChanges = await this.compareProperties(desiredResource.Type, currentCompared, desiredCompared, maskForLog);
4959
- const reported = new Set(propertyChanges.map((pc) => pc.path));
4960
- const rebaselined = [];
4961
- const moved = await movedMaskedProperties(currentResource, rawDesiredProps, maskedInputs && inputFingerprinter(rawDesiredProps, maskedInputs.sources), maskedInputs?.rebaselined && ((key, fingerprint) => rebaselined.push([key, fingerprint])));
4962
- if (rebaselined.length > 0) maskedInputs.rebaselined.set(logicalId, Object.fromEntries(rebaselined));
4963
- for (const key of moved) {
4964
- if (reported.has(key)) continue;
4965
- if (!Object.hasOwn(currentCompared, key)) continue;
4966
- if (!Object.hasOwn(desiredCompared, key)) continue;
4967
- const oldValue = currentCompared[key];
4968
- const newValue = desiredCompared[key];
4969
- propertyChanges.push({
4970
- path: key,
4971
- oldValue,
4972
- newValue,
4973
- requiresReplacement: await this.maskedEditRequiresReplacement(desiredResource.Type, key, oldValue, newValue, {
4974
- oldProperties: currentCompared,
4975
- newProperties: desiredCompared
4976
- }),
4977
- maskedExpressionChanged: true
4978
- });
4979
- this.logger.debug(safeMsg`${logicalId}: ${key} is recorded masked and its template expression or a resolved input changed`);
4980
- }
4981
- const listed = new Set(propertyChanges.map((pc) => pc.path));
4982
- for (const key of unsettledPropertiesOf(currentResource)) {
4983
- if (listed.has(key)) continue;
4984
- propertyChanges.push({
4985
- path: key,
4986
- oldValue: currentCompared[key],
4987
- newValue: desiredCompared[key],
4988
- requiresReplacement: false,
4989
- unsettled: true
4990
- });
4991
- this.logger.debug(safeMsg`${logicalId}: ${key} is unsettled after a failed update and is sent again`);
4992
- }
4993
- const attributeChanges = this.compareAttributes(currentResource, desiredResource);
4994
- if (propertyChanges.length > 0 || attributeChanges.length > 0) {
4995
- const providerReplacement = propertyChanges.length > 0 ? providerReplacementReason(desiredResource.Type, currentResource, resolvedDesiredProps) : void 0;
4996
- changes.set(logicalId, {
4997
- logicalId,
4998
- changeType: "UPDATE",
4999
- resourceType: desiredResource.Type,
5000
- currentProperties: currentResource.properties,
5001
- desiredProperties: rawDesiredProps,
5002
- propertyChanges,
5003
- ...attributeChanges.length > 0 && { attributeChanges },
5004
- ...providerReplacement !== void 0 && { providerReplacement }
5005
- });
5006
- this.logger.debug(`UPDATE: ${logicalId} (${propertyChanges.length} property changes, ${attributeChanges.length} attribute changes)`);
5007
- } else {
5008
- changes.set(logicalId, {
5009
- logicalId,
5010
- changeType: "NO_CHANGE",
5011
- resourceType: desiredResource.Type,
5012
- currentProperties: currentResource.properties,
5013
- desiredProperties: rawDesiredProps
5014
- });
5015
- this.logger.debug(`NO_CHANGE: ${logicalId}`);
5016
- }
5017
- }
5018
- }
5019
- for (const [logicalId, currentResource] of Object.entries(currentResources)) if (!processedLogicalIds.has(logicalId)) {
5020
- changes.set(logicalId, {
5021
- logicalId,
5022
- changeType: "DELETE",
5023
- resourceType: currentResource.resourceType,
5024
- currentProperties: currentResource.properties
5025
- });
5026
- this.logger.debug(`DELETE: ${logicalId} (${currentResource.resourceType})`);
5027
- }
5028
- for (const logicalId of forcedNestedChildRuns ?? []) {
5029
- const change = changes.get(logicalId);
5030
- if (change?.resourceType !== "AWS::CloudFormation::Stack") continue;
5031
- if (change.changeType === "NO_CHANGE") {
5032
- change.changeType = "UPDATE";
5033
- change.propertyChanges = [];
5034
- }
5035
- if (change.changeType === "UPDATE") change.nestedChildHeal = true;
5036
- }
5037
- const forcedReplacements = /* @__PURE__ */ new Set();
5038
- for (const logicalId of recreateTargets ?? []) {
5039
- const changeType = changes.get(logicalId)?.changeType;
5040
- if (changeType === "NO_CHANGE" || changeType === "UPDATE") forcedReplacements.add(logicalId);
5041
- }
5042
- for (const logicalId of markLegacyHandleHeals(changes, currentResources, desiredTemplate, (v) => this.parser.extractReferences(v))) forcedReplacements.add(logicalId);
5043
- const provenanceChanges = await this.promoteReadProvenanceDependents(changes, currentState, desiredTemplate, readProvenance);
5044
- const syntheticCreateOnlyPaths = await this.loadSyntheticCreateOnlyPaths(changes, desiredTemplate, rawGetAttRefs, freshParameters, forcedReplacements);
5045
- for (const { change, pc, upstreams } of provenanceChanges) {
5046
- const templateValue = desiredTemplate.Resources[change.logicalId]?.Properties?.[pc.path];
5047
- pc.requiresReplacement = this.syntheticRequiresReplacement(change.resourceType, pc.path, syntheticCreateOnlyPaths, upstreams.some((id) => isPlainReferenceTo(templateValue, id, desiredTemplate.Resources[id]?.Type)), siblingsOf(change));
5048
- }
5049
- do {
5050
- if (updatePolicy === true) markUpdatePolicyReplacements(changes, desiredTemplate);
5051
- this.promoteReplacementDependents(changes, desiredTemplate, syntheticCreateOnlyPaths, forcedReplacements);
5052
- } while (this.promoteInPlaceAttributeDependents(changes, desiredTemplate, rawGetAttRefs, syntheticCreateOnlyPaths, freshParameters));
5053
- dropSupersededProviderReplacements(changes);
5054
- const summary = this.getSummary(changes);
5055
- this.logger.debug(`Diff calculated: ${summary.create} CREATE, ${summary.update} UPDATE, ${summary.delete} DELETE, ${summary.noChange} NO_CHANGE`);
5056
- return changes;
5057
- }
5058
-
5059
- // src/analyzer/read-provenance-promotion.ts
5060
- function isPlainObject(value) {
5061
- return value !== null && typeof value === "object" && !Array.isArray(value);
5062
- }
5063
- function readsAcrossStacks(value) {
5064
- if (Array.isArray(value)) return value.some(readsAcrossStacks);
5065
- if (!isPlainObject(value)) return false;
5066
- if (Object.hasOwn(value, "Fn::ImportValue") || Object.hasOwn(value, "Fn::GetStackOutput")) return true;
5067
- return Object.values(value).some(readsAcrossStacks);
5068
- }
5069
- function recordedReadVersions(record) {
5070
- if (!isPlainObject(record) || !Object.hasOwn(record, "referenceProvenance")) return void 0;
5071
- const field = referenceProvenanceOf(record);
5072
- if (field === void 0) return void 0;
5073
- let out;
5074
- for (const [token, entry] of Object.entries(field)) if (entry.readVersions !== void 0 && entry.readVersions.length > 0) (out ??= /* @__PURE__ */ new Map()).set(token, entry.readVersions);
5075
- return out;
5076
- }
5077
- async function readProvenancePromotions(args) {
5078
- const { currentState, desiredTemplate, sources } = args;
5079
- const parser = args.parser ?? new TemplateParser();
5080
- const records = currentState.resources;
5081
- const parameters = isPlainObject(desiredTemplate.Parameters) ? desiredTemplate.Parameters : void 0;
5082
- const out = [];
5083
- for (const { logicalId, changeType } of args.rows) {
5084
- if (changeType !== "NO_CHANGE" && changeType !== "UPDATE") continue;
5085
- const record = Object.hasOwn(records, logicalId) ? records[logicalId] : void 0;
5086
- const readVersions = recordedReadVersions(record);
5087
- if (readVersions === void 0) continue;
5088
- const resource = Object.hasOwn(desiredTemplate.Resources, logicalId) ? desiredTemplate.Resources[logicalId] : void 0;
5089
- const properties = isPlainObject(resource?.Properties) ? resource.Properties : {};
5090
- const reads = [];
5091
- for (const [key, value] of Object.entries(properties)) {
5092
- const referenced = [...parser.extractReferences(value)].filter((id) => id !== logicalId);
5093
- const resourceIds = referenced.filter((id) => Object.hasOwn(desiredTemplate.Resources, id));
5094
- const readsParameter = parameters !== void 0 && referenced.some((id) => Object.hasOwn(parameters, id));
5095
- const crossStack = readsAcrossStacks(value);
5096
- if (resourceIds.length === 0 && !readsParameter && !crossStack) continue;
5097
- reads.push({
5098
- key,
5099
- value,
5100
- resources: resourceIds,
5101
- parameters: readsParameter,
5102
- crossStack
5103
- });
5104
- }
5105
- if (reads.length === 0) continue;
5106
- let crossStackBags = [];
5107
- if (sources?.crossStackOutputs !== void 0) {
5108
- const crossValues = reads.filter((r) => r.crossStack).map((r) => r.value);
5109
- if (crossValues.length > 0) crossStackBags = await sources.crossStackOutputs(crossValues);
5110
- }
5111
- const upstreamIds = new Set(reads.flatMap((r) => r.resources));
5112
- const readsAnyParameter = reads.some((r) => r.parameters);
5113
- const moved = [];
5114
- for (const [token, recorded] of readVersions) {
5115
- const domain = /* @__PURE__ */ new Set();
5116
- let member = false;
5117
- const join = (versions) => {
5118
- if (versions === void 0 || versions.length === 0) return;
5119
- member = true;
5120
- for (const version of versions) domain.add(version);
5121
- };
5122
- for (const id of upstreamIds) {
5123
- const upstream = Object.hasOwn(records, id) ? records[id] : void 0;
5124
- join(recordedProvenanceOf(upstream, token)?.versions);
5125
- }
5126
- if (readsAnyParameter && sources?.inherited !== void 0) join(sources.inherited.get(token)?.versions);
5127
- for (const bag of crossStackBags) if (Object.hasOwn(bag, token)) join(bag[token]?.versions);
5128
- if (!member) continue;
5129
- if (recorded.some((version) => !domain.has(version))) moved.push(token);
5130
- }
5131
- if (moved.length === 0) continue;
5132
- const recordProperties = isPlainObject(record?.properties) ? record.properties : {};
5133
- const keys = [];
5134
- for (const r of reads) {
5135
- if (!Object.hasOwn(recordProperties, r.key)) continue;
5136
- const held = referenceTokensIn(recordProperties[r.key]);
5137
- if (!moved.some((token) => held.has(token))) continue;
5138
- keys.push({
5139
- key: r.key,
5140
- upstreams: r.resources
5141
- });
5142
- }
5143
- if (keys.length === 0) continue;
5144
- out.push({
5145
- logicalId,
5146
- keys,
5147
- tokens: moved
5148
- });
5149
- }
5150
- return out;
5151
- }
5152
-
5153
- // src/analyzer/diff-calculator/promotion.ts
5154
- async function promoteReadProvenanceDependents(changes, currentState, desiredTemplate, sources) {
5155
- if (isKnownTokenFreeState(currentState)) return [];
5156
- const promotions = await readProvenancePromotions({
5157
- rows: changes.values(),
5158
- currentState,
5159
- desiredTemplate,
5160
- sources,
5161
- parser: this.parser
5162
- });
5163
- const out = [];
5164
- for (const promotion of promotions) {
5165
- const change = changes.get(promotion.logicalId);
5166
- if (change === void 0) continue;
5167
- const existingPaths = new Set((change.propertyChanges ?? []).map((pc) => pc.path));
5168
- const synthetic = [];
5169
- for (const { key, upstreams } of promotion.keys) {
5170
- if (existingPaths.has(key)) continue;
5171
- const pc = {
5172
- path: key,
5173
- oldValue: change.currentProperties?.[key],
5174
- newValue: change.desiredProperties?.[key],
5175
- requiresReplacement: false,
5176
- inPlacePropagated: true,
5177
- readProvenancePromoted: true
5178
- };
5179
- synthetic.push(pc);
5180
- out.push({
5181
- change,
5182
- pc,
5183
- upstreams
5184
- });
5185
- }
5186
- if (synthetic.length === 0) continue;
5187
- if (change.changeType === "NO_CHANGE") {
5188
- change.changeType = "UPDATE";
5189
- change.propertyChanges = synthetic;
5190
- } else change.propertyChanges = [...change.propertyChanges ?? [], ...synthetic];
5191
- this.logger.debug(safeMsg`UPDATE (promoted): ${promotion.logicalId} holds a secret reference read at a version its upstream no longer records (${synthetic.map((pc) => pc.path).join(", ")})`);
5192
- }
5193
- return out;
5194
- }
5195
- async function loadSyntheticCreateOnlyPaths(changes, desiredTemplate, rawGetAttRefs, freshParameters, forcedReplacements) {
5196
- const loaded = /* @__PURE__ */ new Map();
5197
- const queue = [...freshParameters ?? []];
5198
- for (const [logicalId, change] of changes) if (change.changeType === "UPDATE" || forcedReplacements.has(logicalId)) queue.push(logicalId);
5199
- if (queue.length === 0) return loaded;
5200
- const readersOf = /* @__PURE__ */ new Map();
5201
- const addEdge = (referencedId, readerId) => {
5202
- if (referencedId === readerId) return;
5203
- let readers = readersOf.get(referencedId);
5204
- if (!readers) {
5205
- readers = /* @__PURE__ */ new Set();
5206
- readersOf.set(referencedId, readers);
5207
- }
5208
- readers.add(readerId);
5209
- };
5210
- for (const [logicalId, resource] of Object.entries(desiredTemplate.Resources)) {
5211
- if (resource.Type === "AWS::CDK::Metadata") continue;
5212
- for (const value of Object.values(resource.Properties ?? {})) for (const referencedId of this.parser.extractReferences(value)) addEdge(referencedId, logicalId);
5213
- for (const perUpstream of rawGetAttRefs.get(logicalId)?.values() ?? []) for (const referencedId of perUpstream.keys()) addEdge(referencedId, logicalId);
5214
- }
5215
- const reached = new Set(queue);
5216
- while (queue.length > 0) for (const readerId of readersOf.get(queue.shift()) ?? []) {
5217
- if (reached.has(readerId)) continue;
5218
- reached.add(readerId);
5219
- queue.push(readerId);
5220
- }
5221
- const candidateKeys = /* @__PURE__ */ new Map();
5222
- for (const logicalId of reached) {
5223
- const change = changes.get(logicalId);
5224
- if (!change) continue;
5225
- if (change.changeType !== "NO_CHANGE" && change.changeType !== "UPDATE") continue;
5226
- for (const [key, value] of Object.entries(change.desiredProperties ?? {})) {
5227
- if (this.replacementRules.isClassified(change.resourceType, key)) continue;
5228
- if (!containsIntrinsic(value)) continue;
5229
- let keys = candidateKeys.get(change.resourceType);
5230
- if (!keys) {
5231
- keys = /* @__PURE__ */ new Set();
5232
- candidateKeys.set(change.resourceType, keys);
5233
- }
5234
- keys.add(key);
5235
- }
5236
- }
5237
- const types = candidateKeys.keys();
5238
- await Promise.all([...types].map(async (type) => {
5239
- const whole = new Set((await getCreateOnlyPropertyPaths(type)).filter((path) => path.length === 1).map((path) => path[0]));
5240
- if (![...candidateKeys.get(type)].some((key) => whole.has(key))) {
5241
- loaded.set(type, {
5242
- whole,
5243
- unconfirmable: /* @__PURE__ */ new Set()
5244
- });
5245
- return;
5246
- }
5247
- const writeOnly = await tryGetTopLevelWriteOnlyProperties(type);
5248
- if (writeOnly === void 0) {
5249
- this.logger.debug(safeMsg`Write-only properties of ${type} unknown: no create-only replacement ceiling for its promoted readers but a plain reference to a replaced resource`);
5250
- loaded.set(type, {
5251
- whole,
5252
- unconfirmable: "all"
5253
- });
5254
- return;
5255
- }
5256
- loaded.set(type, {
5257
- whole,
5258
- unconfirmable: new Set([...whole].filter((key) => writeOnly.has(key)))
5259
- });
5260
- }));
5261
- return loaded;
5262
- }
5263
- function syntheticRequiresReplacement(resourceType, propKey, syntheticCreateOnlyPaths, plainReference, siblings) {
5264
- if (this.replacementRules.requiresReplacement(resourceType, propKey, void 0, void 0, siblings)) return true;
5265
- if (this.replacementRules.isClassified(resourceType, propKey)) return false;
5266
- const createOnly = syntheticCreateOnlyPaths.get(resourceType);
5267
- if (createOnly === void 0 || !createOnly.whole.has(propKey)) return false;
5268
- if (plainReference) return true;
5269
- return createOnly.unconfirmable !== "all" && !createOnly.unconfirmable.has(propKey);
5270
- }
5271
- function promoteReplacementDependents(changes, desiredTemplate, syntheticCreateOnlyPaths, forcedReplacements) {
5272
- const queue = [];
5273
- for (const [logicalId, change] of changes) if (forcedReplacements.has(logicalId) || change.changeType === "UPDATE" && change.propertyChanges?.some((pc) => pc.requiresReplacement && pc.noEchoPromoted !== true)) queue.push(logicalId);
5274
- if (queue.length === 0) return;
5275
- const dependentsOf = /* @__PURE__ */ new Map();
5276
- for (const [logicalId, resource] of Object.entries(desiredTemplate.Resources)) {
5277
- if (resource.Type === "AWS::CDK::Metadata") continue;
5278
- for (const [propKey, propValue] of Object.entries(resource.Properties ?? {})) for (const referencedId of this.parser.extractReferences(propValue)) {
5279
- if (referencedId === logicalId) continue;
5280
- let dependents = dependentsOf.get(referencedId);
5281
- if (!dependents) {
5282
- dependents = /* @__PURE__ */ new Map();
5283
- dependentsOf.set(referencedId, dependents);
5284
- }
5285
- let propKeys = dependents.get(logicalId);
5286
- if (!propKeys) {
5287
- propKeys = /* @__PURE__ */ new Set();
5288
- dependents.set(logicalId, propKeys);
5289
- }
5290
- propKeys.add(propKey);
5291
- }
5292
- }
5293
- const enqueued = new Set(queue);
5294
- while (queue.length > 0) {
5295
- const replacedId = queue.shift();
5296
- const dependents = dependentsOf.get(replacedId);
5297
- if (!dependents) continue;
5298
- for (const [dependentId, refPropKeys] of dependents) {
5299
- const change = changes.get(dependentId);
5300
- if (!change) continue;
5301
- if (change.changeType !== "NO_CHANGE" && change.changeType !== "UPDATE") continue;
5302
- const existingPaths = new Set((change.propertyChanges ?? []).map((pc) => pc.path));
5303
- const syntheticChanges = [];
5304
- for (const propKey of refPropKeys) {
5305
- if (existingPaths.has(propKey)) {
5306
- markNewValueKnownAfterDeploy(change, propKey);
5307
- continue;
5308
- }
5309
- const oldValue = change.currentProperties?.[propKey];
5310
- const newValue = change.desiredProperties?.[propKey];
5311
- syntheticChanges.push({
5312
- path: propKey,
5313
- oldValue,
5314
- newValue,
5315
- replacementPropagated: true,
5316
- requiresReplacement: this.syntheticRequiresReplacement(change.resourceType, propKey, syntheticCreateOnlyPaths, isPlainReferenceTo(desiredTemplate.Resources[dependentId]?.Properties?.[propKey], replacedId, desiredTemplate.Resources[replacedId]?.Type), siblingsOf(change)) || namesRecreatedParent(change.resourceType, propKey, changes.get(replacedId)?.resourceType)
5317
- });
5318
- }
5319
- if (syntheticChanges.length === 0) continue;
5320
- if (change.changeType === "NO_CHANGE") {
5321
- change.changeType = "UPDATE";
5322
- change.propertyChanges = syntheticChanges;
5323
- this.logger.debug(`UPDATE (promoted): ${dependentId} references replaced resource ${replacedId} via ${[...refPropKeys].join(", ")}`);
5324
- } else {
5325
- change.propertyChanges = [...change.propertyChanges ?? [], ...syntheticChanges];
5326
- this.logger.debug(`UPDATE (augmented): ${dependentId} references replaced resource ${replacedId} via ${[...refPropKeys].join(", ")}`);
5327
- }
5328
- if (!enqueued.has(dependentId) && change.propertyChanges.some((pc) => pc.requiresReplacement)) {
5329
- enqueued.add(dependentId);
5330
- queue.push(dependentId);
5331
- }
5332
- }
5333
- }
5334
- }
5335
-
5336
- // src/analyzer/diff-calculator/compare.ts
5337
- async function resolveBestEffort(properties, resolveFn) {
5338
- const resolved = {};
5339
- for (const [key, value] of Object.entries(properties)) try {
5340
- const resolvedValue = await resolveFn(structuredClone(value));
5341
- if (resolvedValue === AWS_NO_VALUE) continue;
5342
- resolved[key] = resolvedValue;
5343
- } catch {
5344
- resolved[key] = value;
5345
- }
5346
- return resolved;
5347
- }
5348
- function compareAttributes(currentResource, desiredResource) {
5349
- const changes = [];
5350
- if (currentResource.deletionPolicy !== desiredResource.DeletionPolicy) changes.push({
5351
- attribute: "DeletionPolicy",
5352
- oldValue: currentResource.deletionPolicy,
5353
- newValue: desiredResource.DeletionPolicy
5354
- });
5355
- if (currentResource.updateReplacePolicy !== desiredResource.UpdateReplacePolicy) changes.push({
5356
- attribute: "UpdateReplacePolicy",
5357
- oldValue: currentResource.updateReplacePolicy,
5358
- newValue: desiredResource.UpdateReplacePolicy
5359
- });
5360
- return changes;
5361
- }
5362
- async function compareProperties(resourceType, currentProperties, desiredProperties, maskForLog) {
5363
- const changes = [];
5364
- const allKeys = /* @__PURE__ */ new Set([...Object.keys(currentProperties), ...Object.keys(desiredProperties)]);
5365
- let createOnlyPaths;
5366
- for (const key of allKeys) {
5367
- const oldValue = currentProperties[key];
5368
- const newValue = desiredProperties[key];
5369
- if (!this.valuesEqual(oldValue, newValue)) {
5370
- let requiresReplacement = this.replacementRules.requiresReplacement(resourceType, key, oldValue, newValue, {
5371
- oldProperties: currentProperties,
5372
- newProperties: desiredProperties
5373
- });
5374
- if (!requiresReplacement && !this.replacementRules.isClassified(resourceType, key)) {
5375
- if (createOnlyPaths === void 0) createOnlyPaths = await getCreateOnlyPropertyPaths(resourceType);
5376
- if (createOnlyChangeRequiresReplacement(createOnlyPaths, key, oldValue, newValue, (a, b) => this.valuesEqual(a, b))) {
5377
- requiresReplacement = true;
5378
- this.logger.debug(`Property ${key} of ${resourceType} changed a createOnly path per the CFn schema — requires replacement`);
5379
- }
5380
- }
5381
- changes.push({
5382
- path: key,
5383
- oldValue,
5384
- newValue,
5385
- requiresReplacement
5386
- });
5387
- if (requiresReplacement) {
5388
- const mask = maskerOrIdentity(maskForLog);
5389
- const [oldText, newText] = replacementSidesForLog(oldValue, newValue, mask);
5390
- this.logger.debug(mask(safeMsg`Property ${mask(key)} of ${mask(resourceType)} requires replacement (from ${oldText} to ${newText})`));
5391
- }
5392
- }
5393
- }
5394
- return changes;
5395
- }
5396
- async function maskedEditRequiresReplacement(resourceType, key, oldValue, newValue, siblings) {
5397
- if (this.replacementRules.requiresReplacement(resourceType, key, oldValue, newValue, siblings)) return true;
5398
- if (this.replacementRules.isClassified(resourceType, key) && this.replacementRules.conditionalReplacementVerdict(resourceType, key, oldValue, newValue, siblings) === void 0) return false;
5399
- return (await getCreateOnlyPropertyPaths(resourceType)).some((path) => path.length === 1 && path[0] === key);
5400
- }
5401
- function isIntrinsic(value) {
5402
- if (value === null || value === void 0 || typeof value !== "object" || Array.isArray(value)) return false;
5403
- const keys = Object.keys(value);
5404
- return keys.length === 1 && DiffCalculator.INTRINSIC_KEYS.has(keys[0]);
5405
- }
5406
- function valuesEqual(a, b) {
5407
- if (a === b) return true;
5408
- if (a == null || b == null) return a === b;
5409
- if (DiffCalculator.isIntrinsic(a) !== DiffCalculator.isIntrinsic(b)) return false;
5410
- if (Array.isArray(a) && Array.isArray(b)) {
5411
- if (a.length !== b.length) return false;
5412
- return a.every((val, index) => this.valuesEqual(val, b[index]));
5413
- }
5414
- if (typeof a === "object" && typeof b === "object") {
5415
- const aObj = a;
5416
- const bObj = b;
5417
- const aKeys = Object.keys(aObj);
5418
- const bKeys = Object.keys(bObj);
5419
- if (aKeys.length !== bKeys.length) return false;
5420
- for (const key of bKeys) {
5421
- if (!Object.hasOwn(aObj, key)) return false;
5422
- if (!this.valuesEqual(aObj[key], bObj[key])) return false;
5423
- }
5424
- return true;
5425
- }
5426
- return false;
5427
- }
5428
-
5429
- // src/analyzer/diff-calculator.ts
5430
- var DiffCalculator = class {
5431
- logger = getLogger().child("DiffCalculator");
5432
- replacementRules = new ReplacementRulesRegistry();
5433
- parser = new TemplateParser();
5434
- conditionalReplacementVerdict(resourceType, propertyPath, oldValue, newValue, siblings) {
5435
- return this.replacementRules.conditionalReplacementVerdict(resourceType, propertyPath, oldValue, newValue, siblings);
5436
- }
5437
- calculateDiff(currentState, desiredTemplate, resolveFn, canonicalizeProperties, allowedUnsupportedProperties, freshParameters, maskForLog, recreateTargets, maskedInputs, refusalRecovery, noEchoCompare, readProvenance, forcedNestedChildRuns, updatePolicy) {
5438
- return calculateDiff.call(this, currentState, desiredTemplate, resolveFn, canonicalizeProperties, allowedUnsupportedProperties, freshParameters, maskForLog, recreateTargets, maskedInputs, refusalRecovery, noEchoCompare, readProvenance, forcedNestedChildRuns, updatePolicy);
5439
- }
5440
- promoteReadProvenanceDependents(changes, currentState, desiredTemplate, sources) {
5441
- return promoteReadProvenanceDependents.call(this, changes, currentState, desiredTemplate, sources);
5442
- }
5443
- loadSyntheticCreateOnlyPaths(changes, desiredTemplate, rawGetAttRefs, freshParameters, forcedReplacements) {
5444
- return loadSyntheticCreateOnlyPaths.call(this, changes, desiredTemplate, rawGetAttRefs, freshParameters, forcedReplacements);
5445
- }
5446
- syntheticRequiresReplacement(resourceType, propKey, syntheticCreateOnlyPaths, plainReference, siblings) {
5447
- return syntheticRequiresReplacement.call(this, resourceType, propKey, syntheticCreateOnlyPaths, plainReference, siblings);
5448
- }
5449
- promoteReplacementDependents(changes, desiredTemplate, syntheticCreateOnlyPaths, forcedReplacements) {
5450
- return promoteReplacementDependents.call(this, changes, desiredTemplate, syntheticCreateOnlyPaths, forcedReplacements);
5451
- }
5452
- promoteInPlaceAttributeDependents(changes, desiredTemplate, rawGetAttRefs, syntheticCreateOnlyPaths, freshParameters) {
5453
- return promoteInPlaceAttributeDependents.call(this, changes, desiredTemplate, rawGetAttRefs, syntheticCreateOnlyPaths, freshParameters);
5454
- }
5455
- static extractGetAttRefs(value) {
5456
- return extractGetAttRefs(value);
5457
- }
5458
- resolveBestEffort(properties, resolveFn) {
5459
- return resolveBestEffort.call(this, properties, resolveFn);
5460
- }
5461
- compareAttributes(currentResource, desiredResource) {
5462
- return compareAttributes.call(this, currentResource, desiredResource);
5463
- }
5464
- compareProperties(resourceType, currentProperties, desiredProperties, maskForLog) {
5465
- return compareProperties.call(this, resourceType, currentProperties, desiredProperties, maskForLog);
5466
- }
5467
- maskedEditRequiresReplacement(resourceType, key, oldValue, newValue, siblings) {
5468
- return maskedEditRequiresReplacement.call(this, resourceType, key, oldValue, newValue, siblings);
5469
- }
5470
- static INTRINSIC_KEYS = INTRINSIC_KEYS;
5471
- static isIntrinsic(value) {
5472
- return isIntrinsic(value);
5473
- }
5474
- valuesEqual(a, b) {
5475
- return valuesEqual.call(this, a, b);
5476
- }
5477
- getSummary(changes) {
5478
- const summary = {
5479
- create: 0,
5480
- update: 0,
5481
- delete: 0,
5482
- noChange: 0,
5483
- total: changes.size
5484
- };
5485
- for (const change of changes.values()) switch (change.changeType) {
5486
- case "CREATE":
5487
- summary.create++;
5488
- break;
5489
- case "UPDATE":
5490
- summary.update++;
5491
- break;
5492
- case "DELETE":
5493
- summary.delete++;
5494
- break;
5495
- case "NO_CHANGE": summary.noChange++;
5496
- }
5497
- return summary;
5498
- }
5499
- filterByType(changes, type) {
5500
- return Array.from(changes.values()).filter((change) => change.changeType === type);
5501
- }
5502
- hasChanges(changes) {
5503
- return Array.from(changes.values()).some((change) => change.changeType !== "NO_CHANGE");
5504
- }
5505
- getReplacementChanges(changes) {
5506
- return Array.from(changes.values()).filter((change) => change.changeType === "UPDATE" && change.propertyChanges?.some((pc) => pc.requiresReplacement));
5507
- }
5508
- };
5509
-
5510
4752
  // src/provisioning/settle-own-write-members.ts
5511
4753
  async function settleOwnWriteMembers(result, members, delaysMs, unsettled) {
5512
4754
  await Promise.all(members.map(async (member) => {
@@ -5639,5 +4881,5 @@ function principalOwnWriteMembers(properties, reads, removed) {
5639
4881
  return members;
5640
4882
  }
5641
4883
 
5642
- export { MIGRATE_TMP_PREFIX as $, formatDockerLoginError as A, resolveApp as B, redactDockerArgvValues as C, warnFinchArgvExposure as D, partitionSensitiveEnv as E, Synthesizer as F, resolveStateBucketWithDefaultAndSource as G, resolveCaptureObservedState as H, synthesisStatusMessage as I, resolveUseCdkBootstrapAssets as J, resolveStateBucketWithSource as K, getDefaultStateBucketName as L, runDockerForeground as M, runDockerStreaming as N, isDockerClientEnvKey as O, abortInFlightMultipartUploads as P, CFN_TEMPLATE_URL_LIMIT as Q, getLegacyStateBucketName as R, redactedDockerCause as S, finchSecretArgvRefusal as T, resolveSkipPrefix as U, resolveAutoAssetStorage as V, resolveStateBucketWithDefault as W, warnDeprecatedNoPrefixCliFlag as X, stateBucketExistenceConfirmed as Y, CFN_TEMPLATE_BODY_LIMIT as Z, resolveDockerContextDirectory as _, principalOwnWriteMembers as a, bindLegacyStackAssetParameters as at, describeDockerFailure as b, stringListMember as c, predictedAutoCreatedAssetMode as ct, DagBuilder as d, processStackMessages as dt, findLargeInlineResources as et, LockManager as f, setChildProcessAwsEnv as ft, buildDockerImage as g, WorkGraph as h, mergeDeclaredEntries as i, StageLoadError as it, getDockerCmd as j, isMalformedEnvKey as k, DiffCalculator as l, prepareLegacyStackAssets as lt, AssetPublisher as m, injectedAwsRegionValue as mt, declaredStringList as n, refuseFailedLookups as nt, settleOwnWriteMembers as o, createLegacyAssetParameterBinder as ot, isLockInfoExpired as p, injectAwsRegion as pt, resolveUpdatePolicy as q, inlinePoliciesAreDeclared as r, AssemblyReader as rt, stringListIsDeclared as s, legacyPlanAssetCount as st, declaredInlinePolicies as t, uploadCfnTemplate as tt, LEGACY_HANDLE_HEAL_REASON as u, CdkToolkitBucketMissingError as ut, describeDockerCapturedOutput as v, dockerSpawnEnvWithSensitive as w, redactedCause as x, describeDockerExecFailure as y, loadCdkJson as z };
5643
- //# sourceMappingURL=settle-own-write-members-BJ1rf1Yt.js.map
4884
+ export { createLegacyAssetParameterBinder as $, runDockerForeground as A, resolveCaptureObservedState as B, finchSecretArgvRefusal as C, isMalformedEnvKey as D, isDockerClientEnvKey as E, getDefaultStateBucketName as F, resolveUpdatePolicy as G, resolveStateBucketWithDefault as H, getLegacyStateBucketName as I, warnDeprecatedNoPrefixCliFlag as J, resolveUseCdkBootstrapAssets as K, loadCdkJson as L, abortInFlightMultipartUploads as M, Synthesizer as N, formatDockerLoginError as O, synthesisStatusMessage as P, bindLegacyStackAssetParameters as Q, resolveApp as R, dockerSpawnEnvWithSensitive as S, warnFinchArgvExposure as T, resolveStateBucketWithDefaultAndSource as U, resolveSkipPrefix as V, resolveStateBucketWithSource as W, AssemblyReader as X, refuseFailedLookups as Y, StageLoadError as Z, describeDockerExecFailure as _, principalOwnWriteMembers as a, setChildProcessAwsEnv as at, redactedDockerCause as b, stringListMember as c, isLockInfoExpired as d, legacyPlanAssetCount as et, AssetPublisher as f, describeDockerCapturedOutput as g, resolveDockerContextDirectory as h, mergeDeclaredEntries as i, processStackMessages as it, runDockerStreaming as j, getDockerCmd as k, DagBuilder as l, buildDockerImage as m, declaredStringList as n, prepareLegacyStackAssets as nt, settleOwnWriteMembers as o, injectAwsRegion as ot, WorkGraph as p, stateBucketExistenceConfirmed as q, inlinePoliciesAreDeclared as r, CdkToolkitBucketMissingError as rt, stringListIsDeclared as s, injectedAwsRegionValue as st, declaredInlinePolicies as t, predictedAutoCreatedAssetMode as tt, LockManager as u, describeDockerFailure as v, partitionSensitiveEnv as w, redactDockerArgvValues as x, redactedCause as y, resolveAutoAssetStorage as z };
4885
+ //# sourceMappingURL=settle-own-write-members-D6wzEt7f.js.map