cdk-real-drift 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3040,15 +3040,25 @@ function resolveGeneratedDefault(resourceType, physicalId) {
3040
3040
  return substitutePhysical(tmpl, physicalId, physicalNameOf(physicalId));
3041
3041
  }
3042
3042
  function stripAwsTagsDeep(v) {
3043
- return stripTagsWalk(v, false);
3044
- }
3045
- function stripTagsWalk(v, underTagsKey) {
3046
- if (Array.isArray(v)) return v.filter((t) => !(t && typeof t === "object" && typeof t.Key === "string" && t.Key.startsWith("aws:"))).map((t) => stripTagsWalk(t, false));
3043
+ return stripTagsWalk(v, false, void 0);
3044
+ }
3045
+ const AWS_TAG_FILTER_PROPS = new Set([
3046
+ "TagFilters",
3047
+ "Ec2TagFilters",
3048
+ "Ec2TagSet",
3049
+ "Ec2TagGroup",
3050
+ "TargetTags"
3051
+ ]);
3052
+ function stripTagsWalk(v, underTagsKey, parentKey) {
3053
+ if (Array.isArray(v)) {
3054
+ const underFilter = parentKey !== void 0 && AWS_TAG_FILTER_PROPS.has(parentKey);
3055
+ return v.filter((t) => underFilter || !(t && typeof t === "object" && typeof t.Key === "string" && t.Key.startsWith("aws:"))).map((t) => stripTagsWalk(t, false, void 0));
3056
+ }
3047
3057
  if (v && typeof v === "object") {
3048
3058
  const out = {};
3049
3059
  for (const [k, val] of Object.entries(v)) {
3050
3060
  if (underTagsKey && k.startsWith("aws:")) continue;
3051
- out[k] = stripTagsWalk(val, k === "Tags");
3061
+ out[k] = stripTagsWalk(val, k === "Tags", k);
3052
3062
  }
3053
3063
  return out;
3054
3064
  }
@@ -11390,6 +11400,12 @@ function removeAt(root, segs) {
11390
11400
  //#region src/revert/writers.ts
11391
11401
  const str = (v) => typeof v === "string" && v.length > 0 ? v : void 0;
11392
11402
  const strList = (v) => (Array.isArray(v) ? v : [v]).map(str).filter((s) => s !== void 0);
11403
+ const opTopSeg = (path) => path.replace(/^\//, "").split("/")[0] ?? "";
11404
+ const assertOpsConsumed = (resourceType, ops, handled) => {
11405
+ const isHandled = typeof handled === "function" ? handled : (s) => handled.has(s);
11406
+ const dropped = [...new Set(ops.map((o) => opTopSeg(o.path)).filter((s) => !isHandled(s)))];
11407
+ if (dropped.length > 0) throw new Error(`${resourceType} revert cannot apply ${dropped.join(", ")}: this SDK writer supports only a subset of properties and does not handle ${dropped.length > 1 ? "these" : "this one"}; update ${dropped.length > 1 ? "them" : "it"} manually`);
11408
+ };
11393
11409
  async function desiredModel(type, ctx, ops) {
11394
11410
  const reader = SDK_OVERRIDES[type];
11395
11411
  const current = (reader && await reader(ctx)) ?? {};
@@ -11680,11 +11696,11 @@ const writeDocDbCluster = async (ctx, ops) => {
11680
11696
  else throw new Error(`DocDB DBCluster ${top} cannot be cleared via ModifyDBCluster (its unset state is AWS-assigned/required, not expressible in a selective modify); update it manually`);
11681
11697
  any = true;
11682
11698
  }
11683
- if (!any) return;
11684
- await new DocDBClient({
11699
+ if (any) await new DocDBClient({
11685
11700
  region: ctx.region,
11686
11701
  ...CLIENT_TIMEOUTS
11687
11702
  }).send(new ModifyDBClusterCommand(input));
11703
+ assertOpsConsumed("DocDB DBCluster", ops, DOCDB_CLUSTER_MODIFY_PARAMS);
11688
11704
  };
11689
11705
  const DOCDB_INSTANCE_MODIFY_PARAMS = new Set([
11690
11706
  "DBInstanceClass",
@@ -11709,11 +11725,11 @@ const writeDocDbInstance = async (ctx, ops) => {
11709
11725
  else throw new Error(`DocDB DBInstance ${top} cannot be cleared via ModifyDBInstance (its unset state is AWS-assigned/required, not expressible in a selective modify); update it manually`);
11710
11726
  any = true;
11711
11727
  }
11712
- if (!any) return;
11713
- await new DocDBClient({
11728
+ if (any) await new DocDBClient({
11714
11729
  region: ctx.region,
11715
11730
  ...CLIENT_TIMEOUTS
11716
11731
  }).send(new ModifyDBInstanceCommand(input));
11732
+ assertOpsConsumed("DocDB DBInstance", ops, DOCDB_INSTANCE_MODIFY_PARAMS);
11717
11733
  };
11718
11734
  const writeCloudFrontDistribution = async (ctx, ops) => {
11719
11735
  const id = str(ctx.physicalId);
@@ -11812,6 +11828,7 @@ const writeGlueJob = async (ctx, ops) => {
11812
11828
  JobName: name,
11813
11829
  JobUpdate: update
11814
11830
  }));
11831
+ assertOpsConsumed("Glue Job", ops, (top) => GLUE_JOB_UPDATE_FIELDS.includes(top) || top === "MaxCapacity" || top === "AllocatedCapacity");
11815
11832
  };
11816
11833
  const writeGlueTable = async (ctx, ops) => {
11817
11834
  const m = await desiredModel("AWS::Glue::Table", ctx, ops);
@@ -12088,6 +12105,7 @@ const writeOpenSearchDomain = async (ctx, ops) => {
12088
12105
  } else input[p] = reverted[p];
12089
12106
  }
12090
12107
  await c.send(new UpdateDomainConfigCommand(input));
12108
+ assertOpsConsumed("OpenSearch Domain", ops, OS_UPDATABLE_OPTIONS);
12091
12109
  };
12092
12110
  const writeLogGroupBearerTokenAuth = async (ctx, ops) => {
12093
12111
  const lg = str(ctx.physicalId) ?? str(ctx.declared["LogGroupName"]);
@@ -12230,7 +12248,7 @@ function camelKeysDeep(v) {
12230
12248
  const writeEcsServiceWriteOnlyProps = async (ctx, ops) => {
12231
12249
  const cluster = str(ctx.declared["Cluster"]);
12232
12250
  const service = str(ctx.physicalId);
12233
- if (!cluster || !service) return;
12251
+ if (!cluster || !service) throw new Error("cannot resolve ECS cluster/service for revert");
12234
12252
  const input = {
12235
12253
  cluster,
12236
12254
  service
@@ -12478,6 +12496,7 @@ const writeEc2ClientVpnEndpoint = async (ctx, ops) => {
12478
12496
  ...CLIENT_TIMEOUTS
12479
12497
  }).send(new ModifyClientVpnEndpointCommand(input));
12480
12498
  if (unExpressible.length > 0) throw new Error(`EC2 ClientVpnEndpoint ${unExpressible.join(", ")} cannot be cleared via ModifyClientVpnEndpoint (unset state is not expressible in a selective modify)${any ? "; the other revert op(s) were applied" : ""}; update ${unExpressible.length > 1 ? "them" : "it"} manually`);
12499
+ assertOpsConsumed("EC2 ClientVpnEndpoint", ops, (top) => CLIENT_VPN_SCALAR_PARAMS.has(top) || top === "ConnectionLogOptions" || top === "DnsServers" || top === "SecurityGroupIds");
12481
12500
  };
12482
12501
  const LEX_CFN_TO_LEX_RESOLUTION_STRATEGY = {
12483
12502
  ORIGINAL_VALUE: "OriginalValue",
@@ -12819,11 +12838,11 @@ const writeElasticBeanstalkApplication = async (ctx, ops) => {
12819
12838
  any = true;
12820
12839
  }
12821
12840
  }
12822
- if (!any) return;
12823
- await new ElasticBeanstalkClient({
12841
+ if (any) await new ElasticBeanstalkClient({
12824
12842
  region: ctx.region,
12825
12843
  ...CLIENT_TIMEOUTS
12826
12844
  }).send(new UpdateApplicationCommand(input));
12845
+ assertOpsConsumed("ElasticBeanstalk Application", ops, EB_APPLICATION_MODIFY_PARAMS);
12827
12846
  };
12828
12847
  const EB_ENVIRONMENT_MODIFY_PARAMS = new Set(["Description"]);
12829
12848
  const writeElasticBeanstalkEnvironment = async (ctx, ops) => {
@@ -12838,11 +12857,11 @@ const writeElasticBeanstalkEnvironment = async (ctx, ops) => {
12838
12857
  any = true;
12839
12858
  }
12840
12859
  }
12841
- if (!any) return;
12842
- await new ElasticBeanstalkClient({
12860
+ if (any) await new ElasticBeanstalkClient({
12843
12861
  region: ctx.region,
12844
12862
  ...CLIENT_TIMEOUTS
12845
12863
  }).send(new UpdateEnvironmentCommand(input));
12864
+ assertOpsConsumed("ElasticBeanstalk Environment", ops, EB_ENVIRONMENT_MODIFY_PARAMS);
12846
12865
  };
12847
12866
  const KVS_STREAM_RETENTION_DEFAULT = 0;
12848
12867
  const KVS_CHANNEL_MESSAGE_TTL_DEFAULT = 60;
@@ -12968,6 +12987,7 @@ const writeApiGatewayV2Stage = async (ctx, ops) => {
12968
12987
  input[p] = desired[p];
12969
12988
  }
12970
12989
  if (Object.keys(input).length > 2) await client.send(new UpdateStageCommand(input));
12990
+ assertOpsConsumed("ApiGatewayV2 Stage", ops, APIGWV2_STAGE_UPDATE_FIELDS);
12971
12991
  };
12972
12992
  const writeApiGatewayRestApiPolicy = async (ctx) => {
12973
12993
  const restApiId = str(ctx.physicalId) ?? str(ctx.declared["RestApiId"]);
@@ -13199,6 +13219,12 @@ const REVERT_SET_DEFAULT_PATHS = new Set([
13199
13219
  "AWS::Cognito::UserPool\0MfaConfiguration",
13200
13220
  "AWS::Cognito::UserPool\0UserPoolTier",
13201
13221
  "AWS::Cognito::UserPool\0Policies",
13222
+ "AWS::Cognito::UserPool\0VerificationMessageTemplate",
13223
+ "AWS::Cognito::UserPool\0AccountRecoverySetting",
13224
+ "AWS::Cognito::UserPool\0EmailConfiguration",
13225
+ "AWS::Cognito::UserPool\0KeyConfiguration",
13226
+ "AWS::Cognito::UserPool\0IssuerConfiguration",
13227
+ "AWS::Cognito::UserPool\0WebAuthnFactorConfiguration",
13202
13228
  "AWS::SNS::Subscription\0FilterPolicyScope",
13203
13229
  "AWS::InternetMonitor::Monitor\0Status",
13204
13230
  "AWS::RolesAnywhere::Profile\0DurationSeconds",