cdk-real-drift 0.4.14 → 0.4.16

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
@@ -7,6 +7,7 @@ import { CloudControlClient, DeleteResourceCommand, GetResourceCommand, GetResou
7
7
  import { homedir } from "node:os";
8
8
  import { BaseCredentials, CdkAppMultiContext, NonInteractiveIoHost, StackSelectionStrategy, Toolkit } from "@aws-cdk/toolkit-lib";
9
9
  import { CloudFormationClient, DescribeStackResourcesCommand, DescribeStacksCommand, DescribeTypeCommand, GetTemplateCommand, ListExportsCommand, ListStackResourcesCommand } from "@aws-sdk/client-cloudformation";
10
+ import jsonata from "jsonata";
10
11
  import { KMSClient, ListAliasesCommand } from "@aws-sdk/client-kms";
11
12
  import { APIGatewayClient, GetAuthorizersCommand, GetGatewayResponsesCommand, GetModelsCommand, GetRequestValidatorsCommand, GetResourcesCommand, UpdateIntegrationCommand, UpdateIntegrationResponseCommand, UpdateMethodResponseCommand, UpdateRestApiCommand } from "@aws-sdk/client-api-gateway";
12
13
  import { AppConfigClient, ListConfigurationProfilesCommand, ListEnvironmentsCommand } from "@aws-sdk/client-appconfig";
@@ -4827,6 +4828,47 @@ function expandExecuteApiResources(policy, arnPrefix) {
4827
4828
  Statement: newStmts
4828
4829
  };
4829
4830
  }
4831
+ const transformCache = /* @__PURE__ */ new Map();
4832
+ function compileTransform(expr) {
4833
+ if (transformCache.has(expr)) return transformCache.get(expr) ?? null;
4834
+ let compiled = null;
4835
+ try {
4836
+ compiled = jsonata(expr);
4837
+ } catch {
4838
+ compiled = null;
4839
+ }
4840
+ transformCache.set(expr, compiled);
4841
+ return compiled;
4842
+ }
4843
+ function matchesPropertyTransform(transformExpr, declaredValue, parentObject, rootObject, liveValue, leafName) {
4844
+ const scopes = [
4845
+ parentObject,
4846
+ rootObject,
4847
+ { [leafName]: declaredValue },
4848
+ declaredValue
4849
+ ];
4850
+ for (const alt of transformExpr.split(" $OR ")) {
4851
+ const expr = alt.trim();
4852
+ if (!expr) continue;
4853
+ const compiled = compileTransform(expr);
4854
+ if (!compiled) continue;
4855
+ for (const scope of scopes) try {
4856
+ const out = compiled.evaluate(scope);
4857
+ if (out !== void 0 && deepEqual(out, liveValue)) return true;
4858
+ } catch {}
4859
+ }
4860
+ return false;
4861
+ }
4862
+ function resolveParentObject(root, dottedPath) {
4863
+ const segs = dottedPath.split(".");
4864
+ if (segs.length <= 1) return root;
4865
+ let node = root;
4866
+ for (const seg of segs.slice(0, -1)) {
4867
+ if (node == null || typeof node !== "object") return void 0;
4868
+ node = node[seg];
4869
+ }
4870
+ return node;
4871
+ }
4830
4872
  function classifyResource(resource, liveRaw, schema, opts = {}) {
4831
4873
  const { logicalId, resourceType, physicalId, declared: declaredIn } = resource;
4832
4874
  const findings = [];
@@ -5366,6 +5408,8 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
5366
5408
  declared,
5367
5409
  live
5368
5410
  }) ?? false)) continue;
5411
+ const transformExpr = schema.propertyTransforms?.[d.path] ?? schema.propertyTransforms?.[d.path.replace(/\.\d+(?=\.|$)/g, ".*")];
5412
+ if (transformExpr !== void 0 && matchesPropertyTransform(transformExpr, d.stateValue, resolveParentObject(declared, d.path), declared, d.awsValue, d.path.split(".").at(-1) ?? d.path)) continue;
5369
5413
  const unorderedExtra = unorderedObjArray && Array.isArray(declaredVal) && declaredRemapSource ? {
5370
5414
  path: remapSortedIndexToDeclared(d.path, k, declaredVal, declaredRemapSource),
5371
5415
  wholeArrayRevert: {
@@ -5615,9 +5659,15 @@ function classifyResource(resource, liveRaw, schema, opts = {}) {
5615
5659
 
5616
5660
  //#endregion
5617
5661
  //#region src/read/client-config.ts
5662
+ const CLIENT_TIMEOUTS = { requestHandler: {
5663
+ connectionTimeout: 6e3,
5664
+ requestTimeout: 6e4,
5665
+ throwOnRequestTimeout: true
5666
+ } };
5618
5667
  const READ_RETRY = {
5619
5668
  maxAttempts: 10,
5620
- retryMode: "adaptive"
5669
+ retryMode: "adaptive",
5670
+ ...CLIENT_TIMEOUTS
5621
5671
  };
5622
5672
 
5623
5673
  //#endregion
@@ -9334,6 +9384,8 @@ function parseSchema(schemaJson) {
9334
9384
  const unorderedArrayPaths = collectUnorderedArrayPaths(schema.definitions ?? {}, schema.properties ?? {});
9335
9385
  const freeFormMapPaths = collectFreeFormMapPaths(schema.definitions ?? {}, schema.properties ?? {});
9336
9386
  const updatable = schema.handlers === void 0 ? void 0 : Object.hasOwn(schema.handlers, "update");
9387
+ const propertyTransforms = {};
9388
+ for (const [ptr, expr] of Object.entries(schema.propertyTransform ?? {})) if (typeof expr === "string") propertyTransforms[pointerToDotted$1(ptr)] = expr;
9337
9389
  return {
9338
9390
  readOnly: topLevel(readOnlyPaths),
9339
9391
  writeOnly: topLevel(writeOnlyPaths),
@@ -9346,6 +9398,7 @@ function parseSchema(schemaJson) {
9346
9398
  unorderedScalarPaths: unorderedArrayPaths.scalar,
9347
9399
  unorderedObjectArrayPaths: unorderedArrayPaths.object,
9348
9400
  freeFormMapPaths,
9401
+ ...Object.keys(propertyTransforms).length > 0 && { propertyTransforms },
9349
9402
  updatable
9350
9403
  };
9351
9404
  }
@@ -10626,7 +10679,10 @@ const writeS3BucketPolicy = async (ctx, ops) => {
10626
10679
  const bucket = str(ctx.declared["Bucket"]);
10627
10680
  if (!bucket) throw new Error("cannot resolve bucket for revert");
10628
10681
  const desired = policyJson(await desiredModel("AWS::S3::BucketPolicy", ctx, ops));
10629
- const c = new S3Client({ region: ctx.region });
10682
+ const c = new S3Client({
10683
+ region: ctx.region,
10684
+ ...CLIENT_TIMEOUTS
10685
+ });
10630
10686
  if (desired === void 0) await c.send(new DeleteBucketPolicyCommand({ Bucket: bucket }));
10631
10687
  else await c.send(new PutBucketPolicyCommand({
10632
10688
  Bucket: bucket,
@@ -10637,7 +10693,10 @@ const writeSnsTopicPolicy = async (ctx, ops) => {
10637
10693
  const topics = strList(ctx.declared["Topics"]);
10638
10694
  if (topics.length === 0) throw new Error("cannot resolve topic for revert");
10639
10695
  const desired = policyJson(await desiredModel("AWS::SNS::TopicPolicy", ctx, ops)) ?? "";
10640
- const c = new SNSClient({ region: ctx.region });
10696
+ const c = new SNSClient({
10697
+ region: ctx.region,
10698
+ ...CLIENT_TIMEOUTS
10699
+ });
10641
10700
  for (const topic of topics) await c.send(new SetTopicAttributesCommand({
10642
10701
  TopicArn: topic,
10643
10702
  AttributeName: "Policy",
@@ -10648,7 +10707,10 @@ const writeSqsQueuePolicy = async (ctx, ops) => {
10648
10707
  const queues = strList(ctx.declared["Queues"]);
10649
10708
  if (queues.length === 0) throw new Error("cannot resolve queue for revert");
10650
10709
  const desired = policyJson(await desiredModel("AWS::SQS::QueuePolicy", ctx, ops)) ?? "";
10651
- const c = new SQSClient({ region: ctx.region });
10710
+ const c = new SQSClient({
10711
+ region: ctx.region,
10712
+ ...CLIENT_TIMEOUTS
10713
+ });
10652
10714
  for (const queue of queues) await c.send(new SetQueueAttributesCommand({
10653
10715
  QueueUrl: queue,
10654
10716
  Attributes: { Policy: desired }
@@ -10658,7 +10720,10 @@ const writeEventBusPolicy = async (ctx) => {
10658
10720
  const eventBusName = str(ctx.declared["EventBusName"]) ?? "default";
10659
10721
  const statementId = str(ctx.declared["StatementId"]);
10660
10722
  if (!statementId) throw new Error("cannot resolve StatementId for EventBusPolicy revert");
10661
- const c = new EventBridgeClient({ region: ctx.region });
10723
+ const c = new EventBridgeClient({
10724
+ region: ctx.region,
10725
+ ...CLIENT_TIMEOUTS
10726
+ });
10662
10727
  const declaredStmt = ctx.declared["Statement"];
10663
10728
  let desiredStatement;
10664
10729
  if (declaredStmt && typeof declaredStmt === "object" && !Array.isArray(declaredStmt)) desiredStatement = {
@@ -10701,7 +10766,10 @@ const writeIamPolicy = async (ctx, ops) => {
10701
10766
  if (!name) throw new Error("cannot resolve policy name for revert");
10702
10767
  const desired = policyJson(await desiredModel("AWS::IAM::Policy", ctx, ops));
10703
10768
  if (desired === void 0) throw new Error("cannot revert an IAM inline policy to absent");
10704
- const c = new IAMClient({ region: ctx.region });
10769
+ const c = new IAMClient({
10770
+ region: ctx.region,
10771
+ ...CLIENT_TIMEOUTS
10772
+ });
10705
10773
  const roles = strList(ctx.declared["Roles"]);
10706
10774
  const users = strList(ctx.declared["Users"]);
10707
10775
  const groups = strList(ctx.declared["Groups"]);
@@ -10750,7 +10818,10 @@ const parseAttachmentOp = (o) => {
10750
10818
  const writeIamManagedPolicy = async (ctx, ops) => {
10751
10819
  const arn = isArn(ctx.physicalId) ?? isArn(ctx.declared["ManagedPolicyArn"]);
10752
10820
  if (!arn) throw new Error("cannot resolve managed policy arn for revert");
10753
- const c = new IAMClient({ region: ctx.region });
10821
+ const c = new IAMClient({
10822
+ region: ctx.region,
10823
+ ...CLIENT_TIMEOUTS
10824
+ });
10754
10825
  for (const o of ops) {
10755
10826
  const parsed = parseAttachmentOp(o);
10756
10827
  if (!parsed) continue;
@@ -10800,7 +10871,10 @@ const asInlinePolicies = (v) => Array.isArray(v) ? v.filter((p) => !!p && typeof
10800
10871
  const writeIamRoleInlinePolicies = async (ctx, ops) => {
10801
10872
  const role = str(ctx.physicalId);
10802
10873
  if (!role) throw new Error("cannot resolve role name for revert");
10803
- const c = new IAMClient({ region: ctx.region });
10874
+ const c = new IAMClient({
10875
+ region: ctx.region,
10876
+ ...CLIENT_TIMEOUTS
10877
+ });
10804
10878
  for (const op of ops) {
10805
10879
  if (op.path !== "/Policies") throw new Error(`unsupported inline-policy revert path: ${op.path}`);
10806
10880
  const desired = op.op === "add" ? asInlinePolicies(op.value) : [];
@@ -10825,7 +10899,10 @@ const writeElbLoadBalancerAttributes = async (ctx, ops) => {
10825
10899
  if (!arn) throw new Error("cannot resolve load balancer arn for revert");
10826
10900
  const attrs = elbAttributeOps(ops);
10827
10901
  if (attrs.length === 0) return;
10828
- await new ElasticLoadBalancingV2Client({ region: ctx.region }).send(new ModifyLoadBalancerAttributesCommand({
10902
+ await new ElasticLoadBalancingV2Client({
10903
+ region: ctx.region,
10904
+ ...CLIENT_TIMEOUTS
10905
+ }).send(new ModifyLoadBalancerAttributesCommand({
10829
10906
  LoadBalancerArn: arn,
10830
10907
  Attributes: attrs
10831
10908
  }));
@@ -10835,7 +10912,10 @@ const writeElbTargetGroupAttributes = async (ctx, ops) => {
10835
10912
  if (!arn) throw new Error("cannot resolve target group arn for revert");
10836
10913
  const attrs = elbAttributeOps(ops);
10837
10914
  if (attrs.length === 0) return;
10838
- await new ElasticLoadBalancingV2Client({ region: ctx.region }).send(new ModifyTargetGroupAttributesCommand({
10915
+ await new ElasticLoadBalancingV2Client({
10916
+ region: ctx.region,
10917
+ ...CLIENT_TIMEOUTS
10918
+ }).send(new ModifyTargetGroupAttributesCommand({
10839
10919
  TargetGroupArn: arn,
10840
10920
  Attributes: attrs
10841
10921
  }));
@@ -10844,7 +10924,10 @@ const writeServiceDiscoveryHttpNamespace = async (ctx, ops) => {
10844
10924
  const id = str(ctx.physicalId);
10845
10925
  if (!id) throw new Error("cannot resolve namespace id for revert");
10846
10926
  const m = await desiredModel("AWS::ServiceDiscovery::HttpNamespace", ctx, ops);
10847
- await new ServiceDiscoveryClient({ region: ctx.region }).send(new UpdateHttpNamespaceCommand({
10927
+ await new ServiceDiscoveryClient({
10928
+ region: ctx.region,
10929
+ ...CLIENT_TIMEOUTS
10930
+ }).send(new UpdateHttpNamespaceCommand({
10848
10931
  Id: id,
10849
10932
  Namespace: { Description: str(m.Description) ?? "" }
10850
10933
  }));
@@ -10874,7 +10957,10 @@ const writeDocDbCluster = async (ctx, ops) => {
10874
10957
  any = true;
10875
10958
  }
10876
10959
  if (!any) return;
10877
- await new DocDBClient({ region: ctx.region }).send(new ModifyDBClusterCommand(input));
10960
+ await new DocDBClient({
10961
+ region: ctx.region,
10962
+ ...CLIENT_TIMEOUTS
10963
+ }).send(new ModifyDBClusterCommand(input));
10878
10964
  };
10879
10965
  const DOCDB_INSTANCE_MODIFY_PARAMS = new Set([
10880
10966
  "DBInstanceClass",
@@ -10900,12 +10986,18 @@ const writeDocDbInstance = async (ctx, ops) => {
10900
10986
  any = true;
10901
10987
  }
10902
10988
  if (!any) return;
10903
- await new DocDBClient({ region: ctx.region }).send(new ModifyDBInstanceCommand(input));
10989
+ await new DocDBClient({
10990
+ region: ctx.region,
10991
+ ...CLIENT_TIMEOUTS
10992
+ }).send(new ModifyDBInstanceCommand(input));
10904
10993
  };
10905
10994
  const writeCloudFrontDistribution = async (ctx, ops) => {
10906
10995
  const id = str(ctx.physicalId);
10907
10996
  if (!id) throw new Error("cannot resolve distribution id for revert");
10908
- const c = new CloudFrontClient({ region: ctx.region });
10997
+ const c = new CloudFrontClient({
10998
+ region: ctx.region,
10999
+ ...CLIENT_TIMEOUTS
11000
+ });
10909
11001
  const cur = await c.send(new GetDistributionConfigCommand({ Id: id }));
10910
11002
  if (!cur.DistributionConfig || !cur.ETag) throw new Error("could not read current distribution config for revert");
10911
11003
  const reverted = applyOps({ DistributionConfig: cur.DistributionConfig }, ops);
@@ -10930,7 +11022,10 @@ const WAF_UPDATABLE_PASSTHROUGH = [
10930
11022
  const writeWafv2WebAcl = async (ctx, ops) => {
10931
11023
  const [name, id, scope] = (str(ctx.physicalId) ?? "").split("|");
10932
11024
  if (!name || !id || !scope) throw new Error("cannot resolve WebACL Name|Id|Scope for revert");
10933
- const c = new WAFV2Client({ region: ctx.region });
11025
+ const c = new WAFV2Client({
11026
+ region: ctx.region,
11027
+ ...CLIENT_TIMEOUTS
11028
+ });
10934
11029
  const cur = await c.send(new GetWebACLCommand({
10935
11030
  Name: name,
10936
11031
  Id: id,
@@ -10976,7 +11071,10 @@ const GLUE_JOB_UPDATE_FIELDS = [
10976
11071
  const writeGlueJob = async (ctx, ops) => {
10977
11072
  const name = str(ctx.physicalId) ?? str(ctx.declared["Name"]);
10978
11073
  if (!name) throw new Error("cannot resolve Glue job name for revert");
10979
- const c = new GlueClient({ region: ctx.region });
11074
+ const c = new GlueClient({
11075
+ region: ctx.region,
11076
+ ...CLIENT_TIMEOUTS
11077
+ });
10980
11078
  const got = await c.send(new GetJobCommand({ JobName: name }));
10981
11079
  if (!got.Job) throw new Error("could not read current Glue job for revert");
10982
11080
  const m = applyOps(got.Job, ops);
@@ -10997,7 +11095,10 @@ const writeGlueTable = async (ctx, ops) => {
10997
11095
  const tableInput = m.TableInput;
10998
11096
  if (!dbName || !tableInput || !str(tableInput.Name)) throw new Error("cannot resolve Glue table target for revert");
10999
11097
  const catalogId = str(m.CatalogId) ?? str(ctx.declared["CatalogId"]);
11000
- await new GlueClient({ region: ctx.region }).send(new UpdateTableCommand({
11098
+ await new GlueClient({
11099
+ region: ctx.region,
11100
+ ...CLIENT_TIMEOUTS
11101
+ }).send(new UpdateTableCommand({
11001
11102
  DatabaseName: dbName,
11002
11103
  TableInput: tableInput,
11003
11104
  ...catalogId && { CatalogId: catalogId }
@@ -11019,7 +11120,10 @@ const writeGlueClassifier = async (ctx, ops) => {
11019
11120
  }
11020
11121
  }
11021
11122
  if (Object.keys(input).length === 0) throw new Error("cannot resolve Glue classifier target for revert");
11022
- await new GlueClient({ region: ctx.region }).send(new UpdateClassifierCommand(input));
11123
+ await new GlueClient({
11124
+ region: ctx.region,
11125
+ ...CLIENT_TIMEOUTS
11126
+ }).send(new UpdateClassifierCommand(input));
11023
11127
  };
11024
11128
  const writeGlueWorkflow = async (ctx, ops) => {
11025
11129
  const m = await desiredModel("AWS::Glue::Workflow", ctx, ops);
@@ -11033,7 +11137,10 @@ const writeGlueWorkflow = async (ctx, ops) => {
11033
11137
  if (m.DefaultRunProperties !== void 0) input.DefaultRunProperties = m.DefaultRunProperties;
11034
11138
  else if (removed("DefaultRunProperties")) input.DefaultRunProperties = {};
11035
11139
  if (m.MaxConcurrentRuns !== void 0) input.MaxConcurrentRuns = Number(m.MaxConcurrentRuns);
11036
- await new GlueClient({ region: ctx.region }).send(new UpdateWorkflowCommand(input));
11140
+ await new GlueClient({
11141
+ region: ctx.region,
11142
+ ...CLIENT_TIMEOUTS
11143
+ }).send(new UpdateWorkflowCommand(input));
11037
11144
  };
11038
11145
  const GLUE_CONNECTION_PASSWORD_KEY = /PASSWORD/i;
11039
11146
  const writeGlueConnection = async (ctx, ops) => {
@@ -11045,7 +11152,10 @@ const writeGlueConnection = async (ctx, ops) => {
11045
11152
  const name = str(ci?.Name) ?? str(ctx.physicalId) ?? str(declInput?.Name);
11046
11153
  if (!ci || !name) throw new Error("cannot resolve Glue connection target for revert");
11047
11154
  const catalogId = str(m.CatalogId) ?? str(ctx.declared["CatalogId"]);
11048
- await new GlueClient({ region: ctx.region }).send(new UpdateConnectionCommand({
11155
+ await new GlueClient({
11156
+ region: ctx.region,
11157
+ ...CLIENT_TIMEOUTS
11158
+ }).send(new UpdateConnectionCommand({
11049
11159
  Name: name,
11050
11160
  ...catalogId && { CatalogId: catalogId },
11051
11161
  ConnectionInput: {
@@ -11060,7 +11170,10 @@ const writeSesReceiptRule = async (ctx, ops) => {
11060
11170
  const ruleSetName = str(m.RuleSetName) ?? str(ctx.declared["RuleSetName"]);
11061
11171
  const rule = m.Rule;
11062
11172
  if (!ruleSetName || !rule || !str(rule.Name)) throw new Error("cannot resolve SES receipt rule target for revert");
11063
- await new SESClient({ region: ctx.region }).send(new UpdateReceiptRuleCommand({
11173
+ await new SESClient({
11174
+ region: ctx.region,
11175
+ ...CLIENT_TIMEOUTS
11176
+ }).send(new UpdateReceiptRuleCommand({
11064
11177
  RuleSetName: ruleSetName,
11065
11178
  Rule: rule
11066
11179
  }));
@@ -11080,7 +11193,10 @@ const writeCloudWatchAnomalyDetector = async (ctx, ops) => {
11080
11193
  EndTime: toDate(r.EndTime)
11081
11194
  })) }
11082
11195
  };
11083
- await new CloudWatchClient({ region: ctx.region }).send(new PutAnomalyDetectorCommand({
11196
+ await new CloudWatchClient({
11197
+ region: ctx.region,
11198
+ ...CLIENT_TIMEOUTS
11199
+ }).send(new PutAnomalyDetectorCommand({
11084
11200
  ...single && { SingleMetricAnomalyDetector: single },
11085
11201
  ...math && { MetricMathAnomalyDetector: math },
11086
11202
  ...!single && !math && { SingleMetricAnomalyDetector: {
@@ -11099,7 +11215,10 @@ const writeDlmLifecyclePolicy = async (ctx, ops) => {
11099
11215
  const top = o.path.replace(/^\//, "").split("/")[0] ?? "";
11100
11216
  if (o.op === "remove" && (top === "State" || top === "Description" || top === "ExecutionRoleArn")) throw new Error(`DLM LifecyclePolicy ${top} cannot be cleared via UpdateLifecyclePolicy (no safe clearing value; needs live confirmation); update it manually`);
11101
11217
  }
11102
- const c = new DLMClient({ region: ctx.region });
11218
+ const c = new DLMClient({
11219
+ region: ctx.region,
11220
+ ...CLIENT_TIMEOUTS
11221
+ });
11103
11222
  const m = await desiredModel("AWS::DLM::LifecyclePolicy", ctx, ops);
11104
11223
  let details = m.PolicyDetails;
11105
11224
  if (details === void 0 && DLM_DEFAULT_POLICY_SHORTHAND.some((k) => m[k] !== void 0)) {
@@ -11127,7 +11246,10 @@ const writeMetricFilter = async (ctx, ops) => {
11127
11246
  ...t.Unit !== void 0 && { unit: t.Unit },
11128
11247
  ...t.Dimensions !== void 0 && { dimensions: t.Dimensions }
11129
11248
  }));
11130
- await new CloudWatchLogsClient({ region: ctx.region }).send(new PutMetricFilterCommand({
11249
+ await new CloudWatchLogsClient({
11250
+ region: ctx.region,
11251
+ ...CLIENT_TIMEOUTS
11252
+ }).send(new PutMetricFilterCommand({
11131
11253
  logGroupName: logGroup,
11132
11254
  filterName,
11133
11255
  filterPattern: str(m.FilterPattern) ?? "",
@@ -11160,7 +11282,10 @@ const writeRoute53RecordSet = async (ctx, ops) => {
11160
11282
  if (Array.isArray(m.ResourceRecords)) rrset.ResourceRecords = m.ResourceRecords.map((v) => ({ Value: v }));
11161
11283
  if (m.AliasTarget !== void 0) rrset.AliasTarget = m.AliasTarget;
11162
11284
  for (const k of RR_ROUTING_FIELDS) if (m[k] !== void 0) rrset[k] = m[k];
11163
- await new Route53Client({ region: ctx.region }).send(new ChangeResourceRecordSetsCommand({
11285
+ await new Route53Client({
11286
+ region: ctx.region,
11287
+ ...CLIENT_TIMEOUTS
11288
+ }).send(new ChangeResourceRecordSetsCommand({
11164
11289
  HostedZoneId: zone,
11165
11290
  ChangeBatch: { Changes: [{
11166
11291
  Action: "UPSERT",
@@ -11188,7 +11313,10 @@ const writeConfigRuleInputParameters = async (ctx, ops) => {
11188
11313
  const op = ops.find((o) => o.path === "/InputParameters");
11189
11314
  if (!op) throw new Error("Config rule InputParameters revert: op not found");
11190
11315
  if (op.op !== "add") throw new Error("Config rule InputParameters cannot be cleared via revert: PutConfigRule re-PUTs the whole rule and the exact clearing payload (omit vs empty {}) needs live confirmation; clear it manually");
11191
- const client = new ConfigServiceClient({ region: ctx.region });
11316
+ const client = new ConfigServiceClient({
11317
+ region: ctx.region,
11318
+ ...CLIENT_TIMEOUTS
11319
+ });
11192
11320
  const rule = (await client.send(new DescribeConfigRulesCommand({ ConfigRuleNames: [name] }))).ConfigRules?.[0];
11193
11321
  if (!rule) throw new Error(`Config rule not found for revert: ${name}`);
11194
11322
  const { ConfigRuleArn, ConfigRuleId, ConfigRuleState, CreatedBy, RuleEvaluationVisibility, ...rest } = rule;
@@ -11219,7 +11347,10 @@ const writeOpenSearchDomain = async (ctx, ops) => {
11219
11347
  const name = str(ctx.physicalId) ?? str(ctx.declared["DomainName"]);
11220
11348
  if (!name) throw new Error("cannot resolve OpenSearch domain name for revert");
11221
11349
  const touched = new Set(ops.map((o) => o.path.replace(/^\//, "").split("/")[0]).filter((p) => !!p));
11222
- const c = new OpenSearchClient({ region: ctx.region });
11350
+ const c = new OpenSearchClient({
11351
+ region: ctx.region,
11352
+ ...CLIENT_TIMEOUTS
11353
+ });
11223
11354
  const cfg = (await c.send(new DescribeDomainConfigCommand({ DomainName: name }))).DomainConfig;
11224
11355
  const model = {};
11225
11356
  for (const p of touched) if (cfg?.[p]?.Options !== void 0) model[p] = cfg[p].Options;
@@ -11237,7 +11368,10 @@ const writeOpenSearchDomain = async (ctx, ops) => {
11237
11368
  const writeLogGroupBearerTokenAuth = async (ctx, ops) => {
11238
11369
  const lg = str(ctx.physicalId) ?? str(ctx.declared["LogGroupName"]);
11239
11370
  if (!lg) throw new Error("cannot resolve log group name for revert");
11240
- const c = new CloudWatchLogsClient({ region: ctx.region });
11371
+ const c = new CloudWatchLogsClient({
11372
+ region: ctx.region,
11373
+ ...CLIENT_TIMEOUTS
11374
+ });
11241
11375
  for (const op of ops) {
11242
11376
  const enabled = op.op === "add" ? op.value === true : false;
11243
11377
  await c.send(new PutBearerTokenAuthenticationCommand({
@@ -11249,7 +11383,10 @@ const writeLogGroupBearerTokenAuth = async (ctx, ops) => {
11249
11383
  const writeCognitoIdentityPoolEvents = async (ctx, ops) => {
11250
11384
  const id = str(ctx.physicalId) ?? str(ctx.declared["Id"]);
11251
11385
  if (!id) throw new Error("cannot resolve identity pool id for CognitoEvents revert");
11252
- const c = new CognitoSyncClient({ region: ctx.region });
11386
+ const c = new CognitoSyncClient({
11387
+ region: ctx.region,
11388
+ ...CLIENT_TIMEOUTS
11389
+ });
11253
11390
  const cur = (await c.send(new GetCognitoEventsCommand({ IdentityPoolId: id }))).Events ?? {};
11254
11391
  const events = { ...applyOps({ CognitoEvents: { ...cur } }, ops).CognitoEvents ?? {} };
11255
11392
  for (const k of Object.keys(cur)) if (!(k in events)) events[k] = "";
@@ -11332,7 +11469,10 @@ const writeApiGatewayMethod = async (ctx, ops) => {
11332
11469
  for (const op of ops) for (const p of apigwKnobPatches(op)) if (p.kind === "integration") integrationPatches.push(p.patch);
11333
11470
  else if (p.kind === "integrationResponse") pushByKey(integrationRespPatches, p.statusCode, p.patch);
11334
11471
  else pushByKey(methodRespPatches, p.statusCode, p.patch);
11335
- const c = new APIGatewayClient({ region: ctx.region });
11472
+ const c = new APIGatewayClient({
11473
+ region: ctx.region,
11474
+ ...CLIENT_TIMEOUTS
11475
+ });
11336
11476
  if (integrationPatches.length > 0) await c.send(new UpdateIntegrationCommand({
11337
11477
  restApiId,
11338
11478
  resourceId,
@@ -11379,14 +11519,20 @@ const writeEcsServiceWriteOnlyProps = async (ctx, ops) => {
11379
11519
  const declared = ctx.declared["VolumeConfigurations"];
11380
11520
  input.volumeConfigurations = Array.isArray(declared) ? camelKeysDeep(declared) : [];
11381
11521
  }
11382
- await new ECSClient({ region: ctx.region }).send(new UpdateServiceCommand(input));
11522
+ await new ECSClient({
11523
+ region: ctx.region,
11524
+ ...CLIENT_TIMEOUTS
11525
+ }).send(new UpdateServiceCommand(input));
11383
11526
  };
11384
11527
  const writeMskConfiguration = async (ctx, ops) => {
11385
11528
  const arn = str(ctx.physicalId);
11386
11529
  if (!arn) throw new Error("cannot resolve MSK Configuration ARN for revert");
11387
11530
  const op = ops.find((o) => o.path === "/ServerProperties");
11388
11531
  if (op === void 0 || op.op === "remove" || typeof op.value !== "string") throw new Error("MSK Configuration ServerProperties revert: unexpected op");
11389
- await new KafkaClient({ region: ctx.region }).send(new UpdateConfigurationCommand({
11532
+ await new KafkaClient({
11533
+ region: ctx.region,
11534
+ ...CLIENT_TIMEOUTS
11535
+ }).send(new UpdateConfigurationCommand({
11390
11536
  Arn: arn,
11391
11537
  ServerProperties: new TextEncoder().encode(op.value)
11392
11538
  }));
@@ -11415,7 +11561,10 @@ const writeCodeBuildReportGroup = async (ctx, ops) => {
11415
11561
  key: str(t.Key),
11416
11562
  value: str(t.Value)
11417
11563
  })) : [];
11418
- await new CodeBuildClient({ region: ctx.region }).send(new UpdateReportGroupCommand(input));
11564
+ await new CodeBuildClient({
11565
+ region: ctx.region,
11566
+ ...CLIENT_TIMEOUTS
11567
+ }).send(new UpdateReportGroupCommand(input));
11419
11568
  };
11420
11569
  const DAX_CLUSTER_MODIFY_PARAMS = {
11421
11570
  Description: "Description",
@@ -11441,7 +11590,10 @@ const writeDaxCluster = async (ctx, ops) => {
11441
11590
  any = true;
11442
11591
  }
11443
11592
  if (!any) return;
11444
- await new DAXClient({ region: ctx.region }).send(new UpdateClusterCommand(input));
11593
+ await new DAXClient({
11594
+ region: ctx.region,
11595
+ ...CLIENT_TIMEOUTS
11596
+ }).send(new UpdateClusterCommand(input));
11445
11597
  };
11446
11598
  const writeDaxParameterGroup = async (ctx, ops) => {
11447
11599
  const name = str(ctx.physicalId) ?? str(ctx.declared["ParameterGroupName"]);
@@ -11459,7 +11611,10 @@ const writeDaxParameterGroup = async (ctx, ops) => {
11459
11611
  ParameterValue: desiredValues[k]
11460
11612
  }));
11461
11613
  if (values.length === 0) return;
11462
- await new DAXClient({ region: ctx.region }).send(new UpdateParameterGroupCommand({
11614
+ await new DAXClient({
11615
+ region: ctx.region,
11616
+ ...CLIENT_TIMEOUTS
11617
+ }).send(new UpdateParameterGroupCommand({
11463
11618
  ParameterGroupName: name,
11464
11619
  ParameterNameValues: values
11465
11620
  }));
@@ -11479,7 +11634,10 @@ const writeElastiCacheParameterGroup = async (ctx, ops) => {
11479
11634
  } else if (key !== void 0) modifyKeys.add(key);
11480
11635
  else for (const k of Object.keys(desiredValues)) modifyKeys.add(k);
11481
11636
  }
11482
- const c = new ElastiCacheClient({ region: ctx.region });
11637
+ const c = new ElastiCacheClient({
11638
+ region: ctx.region,
11639
+ ...CLIENT_TIMEOUTS
11640
+ });
11483
11641
  const modify = [...modifyKeys].filter((k) => typeof desiredValues[k] === "string").map((k) => ({
11484
11642
  ParameterName: k,
11485
11643
  ParameterValue: desiredValues[k]
@@ -11510,7 +11668,10 @@ const writeMemoryDbParameterGroup = async (ctx, ops) => {
11510
11668
  } else if (key !== void 0) modifyKeys.add(key);
11511
11669
  else for (const k of Object.keys(desiredValues)) modifyKeys.add(k);
11512
11670
  }
11513
- const c = new MemoryDBClient({ region: ctx.region });
11671
+ const c = new MemoryDBClient({
11672
+ region: ctx.region,
11673
+ ...CLIENT_TIMEOUTS
11674
+ });
11514
11675
  const modify = [...modifyKeys].filter((k) => typeof desiredValues[k] === "string").map((k) => ({
11515
11676
  ParameterName: k,
11516
11677
  ParameterValue: desiredValues[k]
@@ -11574,7 +11735,10 @@ const writeEc2ClientVpnEndpoint = async (ctx, ops) => {
11574
11735
  } else if (removed("SecurityGroupIds")) throw new Error("EC2 ClientVpnEndpoint SecurityGroupIds cannot be cleared via ModifyClientVpnEndpoint (an endpoint cannot revert to no security group in a selective modify); update it manually");
11575
11736
  }
11576
11737
  if (!any) return;
11577
- await new EC2Client({ region: ctx.region }).send(new ModifyClientVpnEndpointCommand(input));
11738
+ await new EC2Client({
11739
+ region: ctx.region,
11740
+ ...CLIENT_TIMEOUTS
11741
+ }).send(new ModifyClientVpnEndpointCommand(input));
11578
11742
  };
11579
11743
  const LEX_CFN_TO_LEX_RESOLUTION_STRATEGY = {
11580
11744
  ORIGINAL_VALUE: "OriginalValue",
@@ -11612,7 +11776,10 @@ const writeLexBotLocales = async (ctx, ops) => {
11612
11776
  if (!botId) throw new Error("cannot resolve Lex Bot id for revert");
11613
11777
  const declaredLocales = ctx.declared["BotLocales"];
11614
11778
  if (!Array.isArray(declaredLocales)) throw new Error("Lex BotLocales revert: declared BotLocales is not an array");
11615
- const c = new LexModelsV2Client({ region: ctx.region });
11779
+ const c = new LexModelsV2Client({
11780
+ region: ctx.region,
11781
+ ...CLIENT_TIMEOUTS
11782
+ });
11616
11783
  const botVersion = "DRAFT";
11617
11784
  for (const rawLocale of declaredLocales) {
11618
11785
  if (!rawLocale || typeof rawLocale !== "object") continue;
@@ -11914,7 +12081,10 @@ const writeElasticBeanstalkApplication = async (ctx, ops) => {
11914
12081
  }
11915
12082
  }
11916
12083
  if (!any) return;
11917
- await new ElasticBeanstalkClient({ region: ctx.region }).send(new UpdateApplicationCommand(input));
12084
+ await new ElasticBeanstalkClient({
12085
+ region: ctx.region,
12086
+ ...CLIENT_TIMEOUTS
12087
+ }).send(new UpdateApplicationCommand(input));
11918
12088
  };
11919
12089
  const EB_ENVIRONMENT_MODIFY_PARAMS = new Set(["Description"]);
11920
12090
  const writeElasticBeanstalkEnvironment = async (ctx, ops) => {
@@ -11930,7 +12100,10 @@ const writeElasticBeanstalkEnvironment = async (ctx, ops) => {
11930
12100
  }
11931
12101
  }
11932
12102
  if (!any) return;
11933
- await new ElasticBeanstalkClient({ region: ctx.region }).send(new UpdateEnvironmentCommand(input));
12103
+ await new ElasticBeanstalkClient({
12104
+ region: ctx.region,
12105
+ ...CLIENT_TIMEOUTS
12106
+ }).send(new UpdateEnvironmentCommand(input));
11934
12107
  };
11935
12108
  const KVS_STREAM_RETENTION_DEFAULT = 0;
11936
12109
  const KVS_CHANNEL_MESSAGE_TTL_DEFAULT = 60;
@@ -11942,7 +12115,10 @@ const writeKinesisVideoStreamRetention = async (ctx, ops) => {
11942
12115
  const op = ops.find((o) => o.path.replace(/^\//, "") === "DataRetentionInHours");
11943
12116
  if (!op) return;
11944
12117
  const target = op.op === "add" && typeof op.value === "number" ? op.value : KVS_STREAM_RETENTION_DEFAULT;
11945
- const kv = new KinesisVideoClient({ region: ctx.region });
12118
+ const kv = new KinesisVideoClient({
12119
+ region: ctx.region,
12120
+ ...CLIENT_TIMEOUTS
12121
+ });
11946
12122
  const desc = await kv.send(new DescribeStreamCommand(kvsStreamRef(id)));
11947
12123
  const current = desc.StreamInfo?.DataRetentionInHours ?? 0;
11948
12124
  const version = desc.StreamInfo?.Version;
@@ -11961,7 +12137,10 @@ const writeKinesisVideoSignalingChannel = async (ctx, ops) => {
11961
12137
  const op = ops.find((o) => o.path.replace(/^\//, "") === "MessageTtlSeconds");
11962
12138
  if (!op) return;
11963
12139
  const target = op.op === "add" && typeof op.value === "number" ? op.value : KVS_CHANNEL_MESSAGE_TTL_DEFAULT;
11964
- const kv = new KinesisVideoClient({ region: ctx.region });
12140
+ const kv = new KinesisVideoClient({
12141
+ region: ctx.region,
12142
+ ...CLIENT_TIMEOUTS
12143
+ });
11965
12144
  const desc = await kv.send(new DescribeSignalingChannelCommand(kvsChannelDescribeRef(id)));
11966
12145
  const arn = desc.ChannelInfo?.ChannelARN;
11967
12146
  const version = desc.ChannelInfo?.Version;
@@ -11979,7 +12158,10 @@ const writeKinesisVideoStreamStorage = async (ctx, ops) => {
11979
12158
  const op = ops.find((o) => o.path.replace(/^\//, "").replace(/\//g, ".").endsWith("DefaultStorageTier"));
11980
12159
  if (!op) return;
11981
12160
  const target = op.op === "add" && typeof op.value === "string" ? op.value : KVS_STREAM_STORAGE_TIER_DEFAULT;
11982
- const kv = new KinesisVideoClient({ region: ctx.region });
12161
+ const kv = new KinesisVideoClient({
12162
+ region: ctx.region,
12163
+ ...CLIENT_TIMEOUTS
12164
+ });
11983
12165
  const version = (await kv.send(new DescribeStreamCommand(kvsStreamRef(id)))).StreamInfo?.Version;
11984
12166
  if (version === void 0) throw new Error(`cannot resolve stream version for ${id}`);
11985
12167
  await kv.send(new UpdateStreamStorageConfigurationCommand({
@@ -12016,7 +12198,10 @@ const writeApiGatewayV2Stage = async (ctx, ops) => {
12016
12198
  }
12017
12199
  return [...keys];
12018
12200
  };
12019
- const client = new ApiGatewayV2Client({ region: ctx.region });
12201
+ const client = new ApiGatewayV2Client({
12202
+ region: ctx.region,
12203
+ ...CLIENT_TIMEOUTS
12204
+ });
12020
12205
  if (touched.has("AccessLogSettings") && isCleared("AccessLogSettings")) await client.send(new DeleteAccessLogSettingsCommand({
12021
12206
  ApiId: apiId,
12022
12207
  StageName: stageName
@@ -12050,7 +12235,10 @@ const writeApiGatewayRestApiPolicy = async (ctx) => {
12050
12235
  if (!restApiId) throw new Error("cannot resolve RestApiId for RestApi Policy revert");
12051
12236
  const declaredPolicy = ctx.declared["Policy"];
12052
12237
  const value = declaredPolicy === void 0 || declaredPolicy === null ? "" : typeof declaredPolicy === "string" ? declaredPolicy : JSON.stringify(declaredPolicy);
12053
- await new APIGatewayClient({ region: ctx.region }).send(new UpdateRestApiCommand({
12238
+ await new APIGatewayClient({
12239
+ region: ctx.region,
12240
+ ...CLIENT_TIMEOUTS
12241
+ }).send(new UpdateRestApiCommand({
12054
12242
  restApiId,
12055
12243
  patchOperations: [{
12056
12244
  op: "replace",
@@ -12134,7 +12322,10 @@ const writeCloudControlIndexNested = async (ctx, ops) => {
12134
12322
  const type = ctx.resourceType;
12135
12323
  if (!type) throw new Error("writeCloudControlIndexNested: resourceType missing on ctx");
12136
12324
  const identifier = ctx.identifier ?? ctx.physicalId;
12137
- const cc = new CloudControlClient({ region: ctx.region });
12325
+ const cc = new CloudControlClient({
12326
+ region: ctx.region,
12327
+ ...CLIENT_TIMEOUTS
12328
+ });
12138
12329
  const got = await cc.send(new GetResourceCommand({
12139
12330
  TypeName: type,
12140
12331
  Identifier: identifier
@@ -13360,7 +13551,10 @@ async function revertStack(p) {
13360
13551
  };
13361
13552
  }
13362
13553
  }
13363
- const cc = new CloudControlClient({ region });
13554
+ const cc = new CloudControlClient({
13555
+ region,
13556
+ ...CLIENT_TIMEOUTS
13557
+ });
13364
13558
  const byLogical = new Map(gathered.desired.resources.map((res) => [res.logicalId, res]));
13365
13559
  const failedDeleteIds = /* @__PURE__ */ new Set();
13366
13560
  const failedUpdateIds = /* @__PURE__ */ new Set();