@cdkd/cli 0.354.0 → 0.356.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 (56) hide show
  1. package/dist/{ambient-client-defaults-BDRSTcYT.js → ambient-client-defaults-DdMbK4P9.js} +3 -3
  2. package/dist/{ambient-client-defaults-BDRSTcYT.js.map → ambient-client-defaults-DdMbK4P9.js.map} +1 -1
  3. package/dist/{asg-provider-DhlT9esh.js → asg-provider-CNU0xa47.js} +6 -6
  4. package/dist/{asg-provider-DhlT9esh.js.map → asg-provider-CNU0xa47.js.map} +1 -1
  5. package/dist/cli.js +3 -3
  6. package/dist/{custom-resource-runtime-Awo4Qqci.js → custom-resource-runtime-I0NaCnMw.js} +6 -6
  7. package/dist/{custom-resource-runtime-Awo4Qqci.js.map → custom-resource-runtime-I0NaCnMw.js.map} +1 -1
  8. package/dist/{db-associated-roles-vY4j5XbM.js → db-associated-roles-DksJGXc2.js} +2 -2
  9. package/dist/{db-associated-roles-vY4j5XbM.js.map → db-associated-roles-DksJGXc2.js.map} +1 -1
  10. package/dist/{delete-started-Dzdlx4Og.js → delete-started-CJaeCjUv.js} +4 -4
  11. package/dist/{delete-started-Dzdlx4Og.js.map → delete-started-CJaeCjUv.js.map} +1 -1
  12. package/dist/{deploy-engine-Th5M81Fb.js → deploy-engine-OG-CIQp9.js} +153 -25
  13. package/dist/deploy-engine-OG-CIQp9.js.map +1 -0
  14. package/dist/{diff-calculator-BHt-qLqK.js → diff-calculator-Cs9j467-.js} +168 -61
  15. package/dist/diff-calculator-Cs9j467-.js.map +1 -0
  16. package/dist/{ec2-termination-protection-BhT7P1Qr.js → ec2-termination-protection-DbyJ2q10.js} +8 -7
  17. package/dist/ec2-termination-protection-DbyJ2q10.js.map +1 -0
  18. package/dist/{ecr-uri-B-QP8AHe.js → ecr-uri-tlBeIkdd.js} +2 -2
  19. package/dist/{ecr-uri-B-QP8AHe.js.map → ecr-uri-tlBeIkdd.js.map} +1 -1
  20. package/dist/{expected-bucket-owner-TY_MPzst.js → expected-bucket-owner-JY3hiATN.js} +2 -2
  21. package/dist/{expected-bucket-owner-TY_MPzst.js.map → expected-bucket-owner-JY3hiATN.js.map} +1 -1
  22. package/dist/{iam-role-provider-KBcDwrRv.js → iam-role-provider-Dqv_R3ru.js} +8 -8
  23. package/dist/{iam-role-provider-KBcDwrRv.js.map → iam-role-provider-Dqv_R3ru.js.map} +1 -1
  24. package/dist/{image-plan-BEsB3Dmo.js → image-plan-DGVKU8RB.js} +8 -8
  25. package/dist/{image-plan-BEsB3Dmo.js.map → image-plan-DGVKU8RB.js.map} +1 -1
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +5 -5
  29. package/dist/{logger-B2SyJOAf.js → logger-DIGYs-yu.js} +2 -2
  30. package/dist/{logger-B2SyJOAf.js.map → logger-DIGYs-yu.js.map} +1 -1
  31. package/dist/{neptune-provider-BR3kEieW.js → neptune-provider-BMraChKs.js} +7 -7
  32. package/dist/{neptune-provider-BR3kEieW.js.map → neptune-provider-BMraChKs.js.map} +1 -1
  33. package/dist/{program-QwXOnrpm.js → program-BikjBQ6T.js} +18 -35
  34. package/dist/program-BikjBQ6T.js.map +1 -0
  35. package/dist/{provider-classes-DMsbNzf6.js → provider-classes-CzitNbPu.js} +876 -165
  36. package/dist/provider-classes-CzitNbPu.js.map +1 -0
  37. package/dist/{rds-provider-D1eagWNh.js → rds-provider-MhOObj_3.js} +10 -10
  38. package/dist/{rds-provider-D1eagWNh.js.map → rds-provider-MhOObj_3.js.map} +1 -1
  39. package/dist/{read-replica-BJFu-OeG.js → read-replica-Cefn8iv7.js} +3 -3
  40. package/dist/{read-replica-BJFu-OeG.js.map → read-replica-Cefn8iv7.js.map} +1 -1
  41. package/dist/{replacement-rules-DhOfKveI.js → replacement-rules-CCuQt7l9.js} +59 -3
  42. package/dist/{replacement-rules-DhOfKveI.js.map → replacement-rules-CCuQt7l9.js.map} +1 -1
  43. package/dist/{resource-deadline-D_epAMej.js → resource-deadline-CzLso0NJ.js} +4 -4
  44. package/dist/{resource-deadline-D_epAMej.js.map → resource-deadline-CzLso0NJ.js.map} +1 -1
  45. package/dist/{restore-source-guard-B_-RdrjK.js → restore-source-guard-qc_YrJ4H.js} +4 -4
  46. package/dist/{restore-source-guard-B_-RdrjK.js.map → restore-source-guard-qc_YrJ4H.js.map} +1 -1
  47. package/dist/{run-cli-ozO7hy96.js → run-cli-DdhQMWgv.js} +2 -2
  48. package/dist/{run-cli-ozO7hy96.js.map → run-cli-DdhQMWgv.js.map} +1 -1
  49. package/dist/{version-snoNU0xA.js → version-Bm3FPycJ.js} +2 -2
  50. package/dist/{version-snoNU0xA.js.map → version-Bm3FPycJ.js.map} +1 -1
  51. package/package.json +2 -2
  52. package/dist/deploy-engine-Th5M81Fb.js.map +0 -1
  53. package/dist/diff-calculator-BHt-qLqK.js.map +0 -1
  54. package/dist/ec2-termination-protection-BhT7P1Qr.js.map +0 -1
  55. package/dist/program-QwXOnrpm.js.map +0 -1
  56. package/dist/provider-classes-DMsbNzf6.js.map +0 -1
@@ -1,16 +1,16 @@
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-snoNU0xA.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-B2SyJOAf.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-BDRSTcYT.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-Bm3FPycJ.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-DIGYs-yu.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-DdMbK4P9.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 { $c as TemplateParser, Al as rememberSynthesizedStacks, Bl as redirectFileAsset, Cs as movedMaskedProperties, El as ssmResolvedValueType, Fl as flattenAssetPlaceholders, Gl as parseAssetManifestBody, Go as referenceProvenanceOf, Il as isDefaultBootstrapBucketName, Jl as warnWholeAssemblyAsSource, Js as refuseMalformedResourceEntriesForDeploy, Kl as resolveFileAssetSourcePath, Ko as referenceTokensIn, Ll as isDefaultBootstrapRepoName, Ol as purgeNoncurrentKeyVersions, Pl as createLazyAssetModeContext, Rl as loadPublishableAssetManifest, Ro as extractGetAttRefs, Tl as isListParameterType, Uo as recordedProvenanceOf, Wl as isCfnTemplateAssetPath, Yc as withoutUnwrittenSdkUnwiredProperties, _l as stringifyValue, _u as namesTheSameDirectory, as as siblingsOf, bs as tryGetTopLevelWriteOnlyProperties, cu as defineOwnKey, du as nullPrototypeRecord, es as namesRecreatedParent, gu as displayAssemblyPath, hu as describeFileReadFailure, is as replacementSidesForLog, jo as AWS_NO_VALUE, mu as assemblyPathEscape, nl as isKnownTokenFreeState, ns as containsIntrinsic, ol as rebuildClientForBucketRegion, ou as getCdkdAssetBucketName, pu as absoluteAssemblyPathEscape, qc as withoutAcceptedSdkUnwiredProperties, ql as warnAbsoluteAssetPath, rc as refuseMalformedResourceProperties, rs as markNewValueKnownAfterDeploy, ss as isPlainReferenceTo, su as getCdkdContainerRepoName, ts as INTRINSIC_KEYS, vl as missingStateBucketRemedy, vu as renderAssemblyPathEscape, wl as SSM_PARAMETER_VALUE_PREFIX, xl as listNestedTemplateRows, xs as inputFingerprinter, xu as resolveBucketRegion, yu as resolveAssemblyPath, zl as redirectDockerAsset, zo as promoteInPlaceAttributeDependents } from "./deploy-engine-Th5M81Fb.js";
7
- import { G as describeJsonParseFailure, K as jsonParseFailureStandIn, L as willReplaceGroup, N as REPLACEMENT_TRIGGER_PROPERTIES, P as changedTriggers, Y as utf8ByteLength, b as getCreateOnlyPropertyPaths, q as parseFailureDebugDetail, y as createOnlyChangeRequiresReplacement } from "./ec2-termination-protection-BhT7P1Qr.js";
6
+ import { Al as purgeNoncurrentKeyVersions, Bl as loadPublishableAssetManifest, Bo as extractGetAttRefs, Cl as listNestedTemplateRows, Cs as inputFingerprinter, Cu as resolveBucketRegion, Dl as isListParameterType, El as SSM_PARAMETER_VALUE_PREFIX, Go as recordedProvenanceOf, Hl as redirectFileAsset, Il as createLazyAssetModeContext, Jl as resolveFileAssetSourcePath, Jo as referenceTokensIn, Kl as isCfnTemplateAssetPath, Ll as flattenAssetPlaceholders, Ml as rememberSynthesizedStacks, No as AWS_NO_VALUE, Ol as ssmResolvedValueType, Rl as isDefaultBootstrapBucketName, Ss as tryGetTopLevelWriteOnlyProperties, Ts as movedMaskedProperties, Vl as redirectDockerAsset, Vo as promoteInPlaceAttributeDependents, Xl as warnWholeAssemblyAsSource, Xs as refuseMalformedResourceEntriesForDeploy, Yc as withoutAcceptedSdkUnwiredProperties, Yl as warnAbsoluteAssetPath, Zc as withoutUnwrittenSdkUnwiredProperties, _u as describeFileReadFailure, ac as refuseMalformedResourceProperties, as as markNewValueKnownAfterDeploy, bl as missingStateBucketRemedy, bu as renderAssemblyPathEscape, cl as rebuildClientForBucketRegion, cu as getCdkdAssetBucketName, gu as assemblyPathEscape, hu as absoluteAssemblyPathEscape, il as isKnownTokenFreeState, is as containsIntrinsic, ls as isPlainReferenceTo, lu as getCdkdContainerRepoName, ns as namesRecreatedParent, os as replacementSidesForLog, pu as nullPrototypeRecord, ql as parseAssetManifestBody, qo as referenceProvenanceOf, rs as INTRINSIC_KEYS, ss as siblingsOf, tl as TemplateParser, uu as defineOwnKey, vu as displayAssemblyPath, xu as resolveAssemblyPath, yl as stringifyValue, yu as namesTheSameDirectory, zl as isDefaultBootstrapRepoName } from "./deploy-engine-OG-CIQp9.js";
7
+ import { G as describeJsonParseFailure, K as jsonParseFailureStandIn, L as willReplaceGroup, N as REPLACEMENT_TRIGGER_PROPERTIES, P as changedTriggers, Y as utf8ByteLength, b as getCreateOnlyPropertyPaths, q as parseFailureDebugDetail, y as createOnlyChangeRequiresReplacement } from "./ec2-termination-protection-DbyJ2q10.js";
8
8
  import { r as derivePartitionAndUrlSuffix } from "./aws-partition-DA0r2sr-.js";
9
- import { Ht as maskerOrIdentity, cn as formatLockOwner, gn as injectiveKey, hn as withPasteableAwsProfile, nn as UNREPRODUCIBLE_LOCK_CLAUSE, on as formatLockExpiry, rn as buildForceUnlockCommand, sn as formatLockOperation } from "./resource-deadline-D_epAMej.js";
10
- import { t as expectedOwnerParam } from "./expected-bucket-owner-TY_MPzst.js";
11
- import { _t as acceptedCreateOnlyDropsOf } from "./delete-started-Dzdlx4Og.js";
12
- import { pn as splitGetAttStringForm, t as ReplacementRulesRegistry } from "./replacement-rules-DhOfKveI.js";
13
- import { S as unsettledPropertiesOf } from "./restore-source-guard-B_-RdrjK.js";
9
+ import { Ht as maskerOrIdentity, cn as formatLockOwner, gn as injectiveKey, hn as withPasteableAwsProfile, nn as UNREPRODUCIBLE_LOCK_CLAUSE, on as formatLockExpiry, rn as buildForceUnlockCommand, sn as formatLockOperation } from "./resource-deadline-CzLso0NJ.js";
10
+ import { t as expectedOwnerParam } from "./expected-bucket-owner-JY3hiATN.js";
11
+ import { _t as acceptedCreateOnlyDropsOf } from "./delete-started-CJaeCjUv.js";
12
+ import { pn as splitGetAttStringForm, t as ReplacementRulesRegistry } from "./replacement-rules-CCuQt7l9.js";
13
+ import { S as unsettledPropertiesOf } from "./restore-source-guard-qc_YrJ4H.js";
14
14
  import { randomBytes, randomUUID } from "node:crypto";
15
15
  import { AbortMultipartUploadCommand, DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, NoSuchKey, PutObjectCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3";
16
16
  import { CloudControlClient, GetResourceCommand, ListResourcesCommand } from "@aws-sdk/client-cloudcontrol";
@@ -1022,6 +1022,16 @@ function parseResourceModel(body, typeName) {
1022
1022
  throw new Error(`Cloud Control returned a resource model for ${displayIdent(typeName)} that is not valid JSON: ${describeJsonParseFailure(err, utf8ByteLength(body))}`);
1023
1023
  }
1024
1024
  }
1025
+ const CC_API_CONTEXT_KEY_PREFIX = "cc-api-provider:";
1026
+ function withoutStaleCcApiContext(context) {
1027
+ const stale = Object.keys(context).filter((key) => key.startsWith(CC_API_CONTEXT_KEY_PREFIX) && !Array.isArray(context[key]));
1028
+ if (stale.length === 0) return context;
1029
+ getLogger().child("CcApiContextProvider").debug(`Re-resolving ${stale.length} cc-api-provider context value(s) stored as an object`);
1030
+ const kept = Object.create(null);
1031
+ for (const [key, value] of Object.entries(context)) if (!stale.includes(key)) kept[key] = value;
1032
+ return kept;
1033
+ }
1034
+ var NoResultsFoundError = class extends Error {};
1025
1035
  var CcApiContextProvider = class {
1026
1036
  logger = getLogger().child("CcApiContextProvider");
1027
1037
  awsConfig;
@@ -1034,100 +1044,103 @@ var CcApiContextProvider = class {
1034
1044
  const exactIdentifier = props["exactIdentifier"];
1035
1045
  const propertiesToReturn = props["propertiesToReturn"] || [];
1036
1046
  const propertyMatch = props["propertyMatch"];
1037
- const expectedMatchCount = props["expectedMatchCount"] || "exactly-one";
1047
+ const expectedMatchCount = props["expectedMatchCount"];
1048
+ const resourceModel = props["resourceModel"];
1038
1049
  const dummyValue = props["dummyValue"];
1039
1050
  const ignoreErrorOnMissingContext = props["ignoreErrorOnMissingContext"];
1040
1051
  if (!typeName) throw new Error("CC API context provider requires typeName property");
1052
+ if (exactIdentifier && propertyMatch) throw new Error("CC API context provider: specify either exactIdentifier or propertyMatch, but not both");
1053
+ if (!exactIdentifier && !propertyMatch) throw new Error("CC API context provider: neither exactIdentifier nor propertyMatch is specified");
1054
+ if (ignoreErrorOnMissingContext && dummyValue === void 0) throw new Error("CC API context provider: if ignoreErrorOnMissingContext is set, a dummyValue must be supplied");
1055
+ 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");
1041
1056
  this.logger.debug(`CC API lookup: ${typeName}${exactIdentifier ? ` (id: ${exactIdentifier})` : ""} (region: ${region})`);
1042
1057
  const client = new CloudControlClient({
1043
1058
  ...ambientClientDefaults(),
1044
1059
  ...region && { region }
1045
1060
  });
1046
1061
  try {
1047
- let resources;
1048
- if (exactIdentifier) {
1049
- const resource = await this.getResource(client, typeName, exactIdentifier);
1050
- resources = resource ? [resource] : [];
1051
- } else {
1052
- resources = await this.listResources(client, typeName);
1053
- if (propertyMatch && Object.keys(propertyMatch).length > 0) resources = resources.filter((r) => this.matchesProperties(r, propertyMatch));
1054
- }
1055
- this.validateMatchCount(resources, expectedMatchCount, typeName, exactIdentifier);
1056
- if (resources.length === 0) {
1057
- if (ignoreErrorOnMissingContext && dummyValue !== void 0) {
1058
- this.logger.debug(`No resources found, returning dummy value`);
1059
- return dummyValue;
1060
- }
1061
- throw new Error(`No ${typeName} resource found${exactIdentifier ? ` with identifier ${exactIdentifier}` : ""}`);
1062
+ return (exactIdentifier ? await this.getResource(client, typeName, exactIdentifier) : await this.listResources(client, typeName, propertyMatch, expectedMatchCount, resourceModel)).map((r) => this.extractProperties(r.properties, r.identifier, propertiesToReturn));
1063
+ } catch (error) {
1064
+ if (error instanceof NoResultsFoundError && ignoreErrorOnMissingContext) {
1065
+ this.logger.debug(`No resources found, returning dummy value`);
1066
+ return dummyValue;
1062
1067
  }
1063
- if (resources.length === 1) return this.extractProperties(resources[0], propertiesToReturn);
1064
- return resources.map((r) => this.extractProperties(r, propertiesToReturn));
1068
+ throw error;
1065
1069
  } finally {
1066
1070
  client.destroy();
1067
1071
  }
1068
1072
  }
1069
1073
  async getResource(client, typeName, identifier) {
1074
+ let response;
1070
1075
  try {
1071
- const response = await client.send(new GetResourceCommand({
1076
+ response = await client.send(new GetResourceCommand({
1072
1077
  TypeName: typeName,
1073
1078
  Identifier: identifier
1074
1079
  }));
1075
- if (!response.ResourceDescription?.Properties) return null;
1076
- return parseResourceModel(response.ResourceDescription.Properties, typeName);
1077
1080
  } catch (error) {
1078
- if (error.name === "ResourceNotFoundException") return null;
1081
+ if (error.name === "ResourceNotFoundException") throw new NoResultsFoundError(`No ${typeName} resource found with identifier ${identifier}`);
1079
1082
  throw error;
1080
1083
  }
1084
+ if (!response.ResourceDescription) throw new Error(`Cloud Control returned an empty response for ${typeName} resource ${identifier}`);
1085
+ return [this.foundResource(response.ResourceDescription, identifier, typeName)];
1081
1086
  }
1082
- async listResources(client, typeName) {
1083
- const resources = [];
1087
+ async listResources(client, typeName, propertyMatch, expectedMatchCount, resourceModel) {
1088
+ const found = [];
1084
1089
  let nextToken;
1085
1090
  do {
1086
1091
  const response = await client.send(new ListResourcesCommand({
1087
1092
  TypeName: typeName,
1093
+ ...resourceModel && { ResourceModel: JSON.stringify(resourceModel) },
1094
+ MaxResults: 100,
1088
1095
  ...nextToken && { NextToken: nextToken }
1089
1096
  }));
1090
- for (const desc of response.ResourceDescriptions ?? []) if (desc.Properties) resources.push(parseResourceModel(desc.Properties, typeName));
1097
+ for (const desc of response.ResourceDescriptions ?? []) {
1098
+ const resource = this.foundResource(desc, "*MISSING*", typeName);
1099
+ if (this.matchesProperties(resource.properties, propertyMatch)) found.push(resource);
1100
+ }
1091
1101
  nextToken = response.NextToken;
1102
+ if ((expectedMatchCount === "at-most-one" || expectedMatchCount === "exactly-one") && found.length > 1) throw new Error(`Expected ${expectedMatchCountText(expectedMatchCount)} ${typeName}, found ${nextToken ? "at least " : ""}${found.length}`);
1092
1103
  } while (nextToken);
1093
- return resources;
1104
+ if ((expectedMatchCount === "at-least-one" || expectedMatchCount === "exactly-one") && found.length === 0) throw new NoResultsFoundError(`Expected ${expectedMatchCountText(expectedMatchCount)} ${typeName}, found none`);
1105
+ return found;
1106
+ }
1107
+ foundResource(desc, fallbackIdentifier, typeName) {
1108
+ return {
1109
+ identifier: desc.Identifier ?? fallbackIdentifier,
1110
+ properties: parseResourceModel(desc.Properties ?? "{}", typeName)
1111
+ };
1094
1112
  }
1095
1113
  matchesProperties(resource, propertyMatch) {
1096
- for (const [key, expectedValue] of Object.entries(propertyMatch)) {
1097
- const actualValue = this.getNestedProperty(resource, key);
1098
- if (JSON.stringify(actualValue) !== JSON.stringify(expectedValue)) return false;
1099
- }
1114
+ for (const [key, expectedValue] of Object.entries(propertyMatch)) if (this.getNestedProperty(resource, key) !== expectedValue) return false;
1100
1115
  return true;
1101
1116
  }
1102
1117
  getNestedProperty(obj, path) {
1103
1118
  const parts = path.split(".");
1104
1119
  let current = obj;
1105
1120
  for (const part of parts) {
1106
- if (current === null || current === void 0 || typeof current !== "object") return;
1121
+ if (current === null || current === void 0) return;
1107
1122
  current = current[part];
1108
1123
  }
1109
1124
  return current;
1110
1125
  }
1111
- validateMatchCount(resources, expectedMatchCount, typeName, identifier) {
1112
- const count = resources.length;
1113
- const context = identifier ? ` with identifier ${identifier}` : "";
1114
- switch (expectedMatchCount) {
1115
- case "exactly-one":
1116
- if (count !== 1) throw new Error(`Expected exactly one ${typeName}${context}, found ${count}`);
1117
- break;
1118
- case "at-least-one":
1119
- if (count < 1) throw new Error(`Expected at least one ${typeName}${context}, found none`);
1120
- break;
1121
- case "at-most-one": if (count > 1) throw new Error(`Expected at most one ${typeName}${context}, found ${count}`);
1122
- }
1123
- }
1124
- extractProperties(resource, propertiesToReturn) {
1125
- if (propertiesToReturn.length === 0) return resource;
1126
+ extractProperties(resource, identifier, propertiesToReturn) {
1126
1127
  const result = {};
1127
1128
  for (const prop of propertiesToReturn) result[prop] = this.getNestedProperty(resource, prop);
1129
+ result["Identifier"] = identifier;
1128
1130
  return result;
1129
1131
  }
1130
1132
  };
1133
+ function isPlainObject$1(value) {
1134
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1135
+ }
1136
+ function expectedMatchCountText(expectedMatchCount) {
1137
+ switch (expectedMatchCount) {
1138
+ case "at-least-one": return "at least one";
1139
+ case "at-most-one": return "at most one";
1140
+ case "exactly-one": return "exactly one";
1141
+ default: return expectedMatchCount;
1142
+ }
1143
+ }
1131
1144
 
1132
1145
  // src/synthesis/context-providers/ami-provider.ts
1133
1146
  var AmiContextProvider = class {
@@ -2004,7 +2017,7 @@ async function resolveStateBucketWithDefaultAndSource(cliBucket, region, legacyF
2004
2017
  const { GetCallerIdentityCommand } = await import("@aws-sdk/client-sts");
2005
2018
  const { S3Client, HeadBucketCommand, ListObjectsV2Command } = await import("@aws-sdk/client-s3");
2006
2019
  const { getAwsClients } = await import("./aws-clients-DOkPjjAW.js").then((n) => n.n);
2007
- const { expectedOwnerParam, recordResolvedAccountId } = await import("./expected-bucket-owner-TY_MPzst.js").then((n) => n.n);
2020
+ const { expectedOwnerParam, recordResolvedAccountId } = await import("./expected-bucket-owner-JY3hiATN.js").then((n) => n.n);
2008
2021
  const probeDeps = {
2009
2022
  HeadBucketCommand,
2010
2023
  ListObjectsV2Command,
@@ -2176,7 +2189,7 @@ var Synthesizer = class {
2176
2189
  ...options.profile && { profile: options.profile }
2177
2190
  });
2178
2191
  while (true) {
2179
- const cdkContextJson = this.contextStore.load();
2192
+ const cdkContextJson = withoutStaleCcApiContext(this.contextStore.load());
2180
2193
  const mergedContext = {
2181
2194
  ...cdkDefaults,
2182
2195
  ...userContext,
@@ -4771,6 +4784,97 @@ function markUpdatePolicyReplacements(changes, desiredTemplate) {
4771
4784
  }
4772
4785
  }
4773
4786
 
4787
+ // src/provisioning/providers/sns-subscription/attribute-plan.ts
4788
+ const MUTABLE_ATTRIBUTES = [
4789
+ "RawMessageDelivery",
4790
+ "FilterPolicy",
4791
+ "FilterPolicyScope",
4792
+ "RedrivePolicy",
4793
+ "DeliveryPolicy",
4794
+ "ReplayPolicy",
4795
+ "SubscriptionRoleArn"
4796
+ ];
4797
+ const RESET_VALUES = {
4798
+ RawMessageDelivery: "false",
4799
+ FilterPolicy: "",
4800
+ FilterPolicyScope: "MessageAttributes",
4801
+ RedrivePolicy: ""
4802
+ };
4803
+ const UNRESETTABLE_REASONS = {
4804
+ DeliveryPolicy: "DeliveryPolicy removed, which SNS cannot reset",
4805
+ ReplayPolicy: "ReplayPolicy removed, which SNS cannot reset",
4806
+ SubscriptionRoleArn: "SubscriptionRoleArn removed, which SNS cannot reset"
4807
+ };
4808
+ function toAttributeValue(key, value) {
4809
+ if (value === void 0) return void 0;
4810
+ if (key === "FilterPolicy" || key === "RedrivePolicy" || key === "DeliveryPolicy" || key === "ReplayPolicy") return typeof value === "string" ? value : JSON.stringify(value);
4811
+ return stringifyValue(value);
4812
+ }
4813
+ function resetValueOf(name) {
4814
+ return Object.hasOwn(RESET_VALUES, name) ? RESET_VALUES[name] : void 0;
4815
+ }
4816
+ function sameAttributeValue(name, desired, current) {
4817
+ if (current === void 0) return desired === resetValueOf(name);
4818
+ if (desired === current) return true;
4819
+ try {
4820
+ return JSON.stringify(JSON.parse(desired)) === JSON.stringify(JSON.parse(current));
4821
+ } catch {
4822
+ return false;
4823
+ }
4824
+ }
4825
+ function filterPolicyCleared(plan, current) {
4826
+ const planned = plan.find(([name]) => name === "FilterPolicy");
4827
+ if (planned !== void 0) return planned[1] === "";
4828
+ return current["FilterPolicy"] === void 0 || current["FilterPolicy"] === "";
4829
+ }
4830
+ function planSubscriptionAttributes(current, properties) {
4831
+ const calls = [];
4832
+ for (const name of MUTABLE_ATTRIBUTES) {
4833
+ const desired = toAttributeValue(name, properties[name]);
4834
+ const now = current[name];
4835
+ if (desired !== void 0) {
4836
+ if (!sameAttributeValue(name, desired, now)) calls.push([name, desired]);
4837
+ continue;
4838
+ }
4839
+ if (now === void 0 || now === "") continue;
4840
+ if (name === "FilterPolicyScope" && filterPolicyCleared(calls, current)) continue;
4841
+ const reset = resetValueOf(name);
4842
+ if (reset === void 0) return {
4843
+ kind: "replace",
4844
+ reason: UNRESETTABLE_REASONS[name]
4845
+ };
4846
+ if (now !== reset) calls.push([name, reset]);
4847
+ }
4848
+ const policy = calls.find(([name]) => name === "FilterPolicy");
4849
+ if (policy !== void 0 && policy[1] !== "" && calls.some(([name]) => name === "FilterPolicyScope")) return {
4850
+ kind: "replace",
4851
+ reason: "FilterPolicy and FilterPolicyScope change together"
4852
+ };
4853
+ return {
4854
+ kind: "in-place",
4855
+ calls
4856
+ };
4857
+ }
4858
+ function recordedSubscriptionAttributes(recorded) {
4859
+ const attributes = {};
4860
+ for (const name of MUTABLE_ATTRIBUTES) attributes[name] = toAttributeValue(name, recorded[name]);
4861
+ return attributes;
4862
+ }
4863
+
4864
+ // src/analyzer/diff-calculator/provider-replacement.ts
4865
+ function providerReplacementReason(resourceType, record, desired) {
4866
+ if (resourceType !== "AWS::SNS::Subscription") return void 0;
4867
+ if (record.resourceType !== resourceType || record.provisionedBy === "cc-api") return void 0;
4868
+ const plan = planSubscriptionAttributes(recordedSubscriptionAttributes(record.properties ?? {}), desired);
4869
+ return plan.kind === "replace" ? plan.reason : void 0;
4870
+ }
4871
+ function dropSupersededProviderReplacements(changes) {
4872
+ for (const change of changes.values()) {
4873
+ if (change.providerReplacement === void 0) continue;
4874
+ if ((change.propertyChanges ?? []).some((pc) => pc.requiresReplacement)) delete change.providerReplacement;
4875
+ }
4876
+ }
4877
+
4774
4878
  // src/analyzer/diff-calculator/calculate-diff.ts
4775
4879
  async function calculateDiff(currentState, desiredTemplate, resolveFn, canonicalizeProperties, allowedUnsupportedProperties, freshParameters, maskForLog, recreateTargets, maskedInputs, refusalRecovery, noEchoCompare, readProvenance, forcedNestedChildRuns, updatePolicy) {
4776
4880
  const changes = /* @__PURE__ */ new Map();
@@ -4881,6 +4985,7 @@ async function calculateDiff(currentState, desiredTemplate, resolveFn, canonical
4881
4985
  }
4882
4986
  const attributeChanges = this.compareAttributes(currentResource, desiredResource);
4883
4987
  if (propertyChanges.length > 0 || attributeChanges.length > 0) {
4988
+ const providerReplacement = propertyChanges.length > 0 ? providerReplacementReason(desiredResource.Type, currentResource, resolvedDesiredProps) : void 0;
4884
4989
  changes.set(logicalId, {
4885
4990
  logicalId,
4886
4991
  changeType: "UPDATE",
@@ -4888,7 +4993,8 @@ async function calculateDiff(currentState, desiredTemplate, resolveFn, canonical
4888
4993
  currentProperties: currentResource.properties,
4889
4994
  desiredProperties: rawDesiredProps,
4890
4995
  propertyChanges,
4891
- ...attributeChanges.length > 0 && { attributeChanges }
4996
+ ...attributeChanges.length > 0 && { attributeChanges },
4997
+ ...providerReplacement !== void 0 && { providerReplacement }
4892
4998
  });
4893
4999
  this.logger.debug(`UPDATE: ${logicalId} (${propertyChanges.length} property changes, ${attributeChanges.length} attribute changes)`);
4894
5000
  } else {
@@ -4936,6 +5042,7 @@ async function calculateDiff(currentState, desiredTemplate, resolveFn, canonical
4936
5042
  if (updatePolicy === true) markUpdatePolicyReplacements(changes, desiredTemplate);
4937
5043
  this.promoteReplacementDependents(changes, desiredTemplate, syntheticCreateOnlyPaths, forcedReplacements);
4938
5044
  } while (this.promoteInPlaceAttributeDependents(changes, desiredTemplate, rawGetAttRefs, syntheticCreateOnlyPaths, freshParameters));
5045
+ dropSupersededProviderReplacements(changes);
4939
5046
  const summary = this.getSummary(changes);
4940
5047
  this.logger.debug(`Diff calculated: ${summary.create} CREATE, ${summary.update} UPDATE, ${summary.delete} DELETE, ${summary.noChange} NO_CHANGE`);
4941
5048
  return changes;
@@ -5395,5 +5502,5 @@ var DiffCalculator = class {
5395
5502
  }
5396
5503
  };
5397
5504
 
5398
- export { predictedAutoCreatedAssetMode as $, loadCdkJson as A, stateBucketExistenceConfirmed as B, runDockerForeground as C, synthesisStatusMessage as D, Synthesizer as E, resolveStateBucketWithDefault as F, findLargeInlineResources as G, CFN_TEMPLATE_BODY_LIMIT as H, resolveStateBucketWithDefaultAndSource as I, AssemblyReader as J, uploadCfnTemplate as K, resolveStateBucketWithSource as L, resolveAutoAssetStorage as M, resolveCaptureObservedState as N, getDefaultStateBucketName as O, resolveSkipPrefix as P, legacyPlanAssetCount as Q, resolveUpdatePolicy as R, getDockerCmd as S, abortInFlightMultipartUploads as T, CFN_TEMPLATE_URL_LIMIT as U, warnDeprecatedNoPrefixCliFlag as V, MIGRATE_TMP_PREFIX as W, bindLegacyStackAssetParameters as X, StageLoadError as Y, createLegacyAssetParameterBinder as Z, partitionSensitiveEnv as _, AssetPublisher as a, injectedAwsRegionValue as at, isMalformedEnvKey as b, resolveDockerContextDirectory as c, describeDockerFailure as d, prepareLegacyStackAssets as et, redactedCause as f, finchSecretArgvRefusal as g, dockerSpawnEnvWithSensitive as h, isLockInfoExpired as i, injectAwsRegion as it, resolveApp as j, getLegacyStateBucketName as k, describeDockerCapturedOutput as l, redactDockerArgvValues as m, DagBuilder as n, processStackMessages as nt, WorkGraph as o, redactedDockerCause as p, refuseFailedLookups as q, LockManager as r, setChildProcessAwsEnv as rt, buildDockerImage as s, DiffCalculator as t, CdkToolkitBucketMissingError as tt, describeDockerExecFailure as u, warnFinchArgvExposure as v, runDockerStreaming as w, formatDockerLoginError as x, isDockerClientEnvKey as y, resolveUseCdkBootstrapAssets as z };
5399
- //# sourceMappingURL=diff-calculator-BHt-qLqK.js.map
5505
+ export { legacyPlanAssetCount as $, getLegacyStateBucketName as A, resolveUseCdkBootstrapAssets as B, getDockerCmd as C, Synthesizer as D, abortInFlightMultipartUploads as E, resolveSkipPrefix as F, MIGRATE_TMP_PREFIX as G, warnDeprecatedNoPrefixCliFlag as H, resolveStateBucketWithDefault as I, refuseFailedLookups as J, findLargeInlineResources as K, resolveStateBucketWithDefaultAndSource as L, resolveApp as M, resolveAutoAssetStorage as N, synthesisStatusMessage as O, resolveCaptureObservedState as P, createLegacyAssetParameterBinder as Q, resolveStateBucketWithSource as R, formatDockerLoginError as S, runDockerStreaming as T, CFN_TEMPLATE_BODY_LIMIT as U, stateBucketExistenceConfirmed as V, CFN_TEMPLATE_URL_LIMIT as W, StageLoadError as X, AssemblyReader as Y, bindLegacyStackAssetParameters as Z, finchSecretArgvRefusal as _, isLockInfoExpired as a, injectAwsRegion as at, isDockerClientEnvKey as b, buildDockerImage as c, describeDockerExecFailure as d, predictedAutoCreatedAssetMode as et, describeDockerFailure as f, dockerSpawnEnvWithSensitive as g, redactDockerArgvValues as h, LockManager as i, setChildProcessAwsEnv as it, loadCdkJson as j, getDefaultStateBucketName as k, resolveDockerContextDirectory as l, redactedDockerCause as m, planSubscriptionAttributes as n, CdkToolkitBucketMissingError as nt, AssetPublisher as o, injectedAwsRegionValue as ot, redactedCause as p, uploadCfnTemplate as q, DagBuilder as r, processStackMessages as rt, WorkGraph as s, DiffCalculator as t, prepareLegacyStackAssets as tt, describeDockerCapturedOutput as u, partitionSensitiveEnv as v, runDockerForeground as w, isMalformedEnvKey as x, warnFinchArgvExposure as y, resolveUpdatePolicy as z };
5506
+ //# sourceMappingURL=diff-calculator-Cs9j467-.js.map