@go-to-k/cdkd 0.106.0 → 0.107.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.
- package/dist/cli.js +147 -40
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -35,7 +35,7 @@ import { Command, Option } from "commander";
|
|
|
35
35
|
import { writeFileSync as writeFileSync$1 } from "fs";
|
|
36
36
|
import { join as join$1 } from "path";
|
|
37
37
|
import * as zlib from "node:zlib";
|
|
38
|
-
import { ApplicationAutoScalingClient, DescribeScalingPoliciesCommand } from "@aws-sdk/client-application-auto-scaling";
|
|
38
|
+
import { ApplicationAutoScalingClient, DescribeScalableTargetsCommand, DescribeScalingPoliciesCommand } from "@aws-sdk/client-application-auto-scaling";
|
|
39
39
|
import { ApiGatewayV2Client, CreateApiCommand, CreateAuthorizerCommand as CreateAuthorizerCommand$1, CreateIntegrationCommand, CreateRouteCommand as CreateRouteCommand$1, CreateStageCommand as CreateStageCommand$1, DeleteApiCommand, DeleteAuthorizerCommand as DeleteAuthorizerCommand$1, DeleteIntegrationCommand, DeleteRouteCommand as DeleteRouteCommand$1, DeleteStageCommand as DeleteStageCommand$1, GetApiCommand, GetApisCommand, GetAuthorizerCommand as GetAuthorizerCommand$1, GetIntegrationCommand, GetRouteCommand, GetStageCommand as GetStageCommand$1, NotFoundException as NotFoundException$3, UpdateApiCommand, UpdateAuthorizerCommand as UpdateAuthorizerCommand$1, UpdateIntegrationCommand, UpdateRouteCommand, UpdateStageCommand as UpdateStageCommand$1 } from "@aws-sdk/client-apigatewayv2";
|
|
40
40
|
import { CreateStateMachineCommand, DeleteStateMachineCommand, DescribeStateMachineCommand, ListStateMachinesCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$9, SFNClient, StateMachineDoesNotExist, TagResourceCommand as TagResourceCommand$10, UntagResourceCommand as UntagResourceCommand$9, UpdateStateMachineCommand } from "@aws-sdk/client-sfn";
|
|
41
41
|
import { CreateClusterCommand, CreateServiceCommand, DeleteClusterCommand, DeleteServiceCommand, DeregisterTaskDefinitionCommand, DescribeClustersCommand, DescribeServicesCommand, DescribeTaskDefinitionCommand, ECSClient, ListClustersCommand, ListServicesCommand, ListTagsForResourceCommand as ListTagsForResourceCommand$10, PutClusterCapacityProvidersCommand, RegisterTaskDefinitionCommand, TagResourceCommand as TagResourceCommand$11, UntagResourceCommand as UntagResourceCommand$10, UpdateClusterCommand, UpdateServiceCommand } from "@aws-sdk/client-ecs";
|
|
@@ -7899,6 +7899,18 @@ var DynamoDBGlobalTableProvider = class {
|
|
|
7899
7899
|
*/
|
|
7900
7900
|
regionalClientCache = /* @__PURE__ */ new Map();
|
|
7901
7901
|
/**
|
|
7902
|
+
* Caches per-region `ApplicationAutoScalingClient` instances for
|
|
7903
|
+
* per-replica `ReadCapacityAutoScalingSettings` reverse-mapping in
|
|
7904
|
+
* `readCurrentState`. Same lifetime / shape as `regionalClientCache`
|
|
7905
|
+
* — one per region for the duration of the provider instance.
|
|
7906
|
+
*
|
|
7907
|
+
* Issue #395: per-replica read capacity autoscaling lives in the
|
|
7908
|
+
* replica's region (each replica has its own scaling target +
|
|
7909
|
+
* policy registered against `application-autoscaling` in that
|
|
7910
|
+
* region), so we cannot reuse the local-region client.
|
|
7911
|
+
*/
|
|
7912
|
+
regionalAutoScalingClientCache = /* @__PURE__ */ new Map();
|
|
7913
|
+
/**
|
|
7902
7914
|
* Caches `getAttribute(physicalId, attribute)` results for the lifetime
|
|
7903
7915
|
* of this provider instance (one deploy run). Safe under the current
|
|
7904
7916
|
* `update()` contract because `update()` cannot mid-deploy mutate
|
|
@@ -7954,6 +7966,24 @@ var DynamoDBGlobalTableProvider = class {
|
|
|
7954
7966
|
return client;
|
|
7955
7967
|
}
|
|
7956
7968
|
/**
|
|
7969
|
+
* Return an `ApplicationAutoScalingClient` pinned to the given region,
|
|
7970
|
+
* caching per region for the lifetime of this provider instance. Mirrors
|
|
7971
|
+
* `getRegionalClient` but for the application-autoscaling service.
|
|
7972
|
+
*
|
|
7973
|
+
* Used by `readAutoScalingSettings` (Issue #395) to recover per-replica
|
|
7974
|
+
* `ReadCapacityAutoScalingSettings` shapes — each cross-region replica's
|
|
7975
|
+
* scaling target + policy are registered with the autoscaling control
|
|
7976
|
+
* plane in the replica's region, so cross-region drift reads need a
|
|
7977
|
+
* region-scoped client.
|
|
7978
|
+
*/
|
|
7979
|
+
getRegionalAutoScalingClient(region) {
|
|
7980
|
+
const cached = this.regionalAutoScalingClientCache.get(region);
|
|
7981
|
+
if (cached) return cached;
|
|
7982
|
+
const client = new ApplicationAutoScalingClient({ region });
|
|
7983
|
+
this.regionalAutoScalingClientCache.set(region, client);
|
|
7984
|
+
return client;
|
|
7985
|
+
}
|
|
7986
|
+
/**
|
|
7957
7987
|
* Construct the regional table ARN for a cross-region replica of a
|
|
7958
7988
|
* GlobalTable. AWS replicates the same `TableName` across every
|
|
7959
7989
|
* replica region, with each replica's ARN differing only in the
|
|
@@ -8493,13 +8523,17 @@ var DynamoDBGlobalTableProvider = class {
|
|
|
8493
8523
|
* - StreamSpecification / SSESpecification follow the existing
|
|
8494
8524
|
* DynamoDB::Table provider's Class 1 guard: only surfaced when AWS
|
|
8495
8525
|
* reports the feature actually enabled.
|
|
8496
|
-
* - `
|
|
8497
|
-
* `
|
|
8498
|
-
*
|
|
8499
|
-
*
|
|
8500
|
-
* `
|
|
8501
|
-
* `
|
|
8502
|
-
*
|
|
8526
|
+
* - `WriteProvisionedThroughputSettings` reverse-maps both shapes:
|
|
8527
|
+
* flat `{WriteCapacityUnits}` (no autoscaling) and full
|
|
8528
|
+
* `{WriteCapacityAutoScalingSettings}` (Issue #395; recovered from
|
|
8529
|
+
* application-autoscaling's `DescribeScalableTargets` +
|
|
8530
|
+
* `DescribeScalingPolicies` for the
|
|
8531
|
+
* `dynamodb:table:WriteCapacityUnits` dimension).
|
|
8532
|
+
* - Per-replica `ReadProvisionedThroughputSettings` reverse-maps the
|
|
8533
|
+
* `{ReadCapacityAutoScalingSettings}` shape only — there is no
|
|
8534
|
+
* per-replica flat read capacity in `DescribeTable`'s response
|
|
8535
|
+
* (the local `ProvisionedThroughput` block is table-level, not
|
|
8536
|
+
* replica-level), so non-autoscaled replicas omit the key.
|
|
8503
8537
|
*
|
|
8504
8538
|
* Per-replica sub-specifications (`ContributorInsightsSpecification` /
|
|
8505
8539
|
* `PointInTimeRecoverySpecification` / `KinesisStreamSpecification`)
|
|
@@ -8555,15 +8589,23 @@ var DynamoDBGlobalTableProvider = class {
|
|
|
8555
8589
|
}
|
|
8556
8590
|
}
|
|
8557
8591
|
else entry["Tags"] = [];
|
|
8592
|
+
if (billingMode === "PROVISIONED") {
|
|
8593
|
+
const replicaAutoScalingClient = isLocal ? void 0 : this.getRegionalAutoScalingClient(regionLabel);
|
|
8594
|
+
const readAutoScaling = await this.readAutoScalingSettings(tableNameForSubs, "dynamodb:table:ReadCapacityUnits", replicaAutoScalingClient);
|
|
8595
|
+
if (readAutoScaling) entry["ReadProvisionedThroughputSettings"] = { ReadCapacityAutoScalingSettings: readAutoScaling };
|
|
8596
|
+
}
|
|
8558
8597
|
return entry;
|
|
8559
8598
|
}));
|
|
8560
8599
|
if (table.OnDemandThroughput?.MaxWriteRequestUnits !== void 0) result["WriteOnDemandThroughputSettings"] = { MaxWriteRequestUnits: table.OnDemandThroughput.MaxWriteRequestUnits };
|
|
8561
8600
|
else result["WriteOnDemandThroughputSettings"] = {};
|
|
8562
8601
|
if (billingMode === "PROVISIONED") {
|
|
8563
|
-
const
|
|
8564
|
-
if (
|
|
8565
|
-
else
|
|
8566
|
-
|
|
8602
|
+
const autoScaling = await this.readAutoScalingSettings(tableNameForSubs, "dynamodb:table:WriteCapacityUnits");
|
|
8603
|
+
if (autoScaling) result["WriteProvisionedThroughputSettings"] = { WriteCapacityAutoScalingSettings: autoScaling };
|
|
8604
|
+
else {
|
|
8605
|
+
const writeCapacity = table.ProvisionedThroughput?.WriteCapacityUnits;
|
|
8606
|
+
if (writeCapacity !== void 0) result["WriteProvisionedThroughputSettings"] = { WriteCapacityUnits: writeCapacity };
|
|
8607
|
+
else result["WriteProvisionedThroughputSettings"] = {};
|
|
8608
|
+
}
|
|
8567
8609
|
} else result["WriteProvisionedThroughputSettings"] = {};
|
|
8568
8610
|
try {
|
|
8569
8611
|
const ttlDesc = (await this.dynamoDBClient.send(new DescribeTimeToLiveCommand({ TableName: tableNameForSubs }))).TimeToLiveDescription;
|
|
@@ -8629,29 +8671,90 @@ var DynamoDBGlobalTableProvider = class {
|
|
|
8629
8671
|
return out;
|
|
8630
8672
|
}
|
|
8631
8673
|
/**
|
|
8632
|
-
*
|
|
8633
|
-
*
|
|
8634
|
-
*
|
|
8635
|
-
*
|
|
8636
|
-
*
|
|
8637
|
-
*
|
|
8638
|
-
*
|
|
8639
|
-
*
|
|
8640
|
-
*
|
|
8641
|
-
*
|
|
8642
|
-
*
|
|
8643
|
-
*
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8674
|
+
* Reverse-map application-autoscaling state for the given DynamoDB table
|
|
8675
|
+
* dimension into the CFn `*CapacityAutoScalingSettings` shape (Issue
|
|
8676
|
+
* #395). Used for BOTH the table-level write dimension
|
|
8677
|
+
* (`dynamodb:table:WriteCapacityUnits`) and the per-replica read
|
|
8678
|
+
* dimension (`dynamodb:table:ReadCapacityUnits`); the CFn shape is
|
|
8679
|
+
* symmetric.
|
|
8680
|
+
*
|
|
8681
|
+
* Returns shape (CFn-canonical PascalCase keys, verified via `cdk synth`
|
|
8682
|
+
* on a real `TableV2` with `Capacity.autoscaled(...)` on 2026-05-16 —
|
|
8683
|
+
* see PR notes for the probe transcript):
|
|
8684
|
+
*
|
|
8685
|
+
* ```
|
|
8686
|
+
* {
|
|
8687
|
+
* MinCapacity: number;
|
|
8688
|
+
* MaxCapacity: number;
|
|
8689
|
+
* TargetTrackingScalingPolicyConfiguration: {
|
|
8690
|
+
* TargetValue: number;
|
|
8691
|
+
* DisableScaleIn?: boolean;
|
|
8692
|
+
* ScaleInCooldown?: number;
|
|
8693
|
+
* ScaleOutCooldown?: number;
|
|
8694
|
+
* };
|
|
8695
|
+
* }
|
|
8696
|
+
* ```
|
|
8697
|
+
*
|
|
8698
|
+
* `SeedCapacity` is intentionally NOT round-tripped — it is a CFn
|
|
8699
|
+
* create-only field with no corresponding application-autoscaling
|
|
8700
|
+
* surface (AWS does not retain the initial seed value once the
|
|
8701
|
+
* scaling target is registered).
|
|
8702
|
+
*
|
|
8703
|
+
* Resolution order:
|
|
8704
|
+
* 1. `DescribeScalableTargets` → recover `MinCapacity` / `MaxCapacity`
|
|
8705
|
+
* for the matching `ScalableDimension`. Returns `null` when no
|
|
8706
|
+
* target is registered (= no autoscaling in play for this
|
|
8707
|
+
* dimension — caller falls back to the flat capacity surface).
|
|
8708
|
+
* 2. `DescribeScalingPolicies` → find the `TargetTrackingScaling`
|
|
8709
|
+
* policy (filter out `StepScaling` / `PredictiveScaling` — CFn's
|
|
8710
|
+
* shape only carries the target-tracking variant). Returns `null`
|
|
8711
|
+
* when no `TargetTrackingScaling` policy is present (a scaling
|
|
8712
|
+
* target without a target-tracking policy is not cdkd-managed
|
|
8713
|
+
* drift territory; surface the flat capacity instead).
|
|
8714
|
+
*
|
|
8715
|
+
* Best-effort: any error (permissions gap, throttle, network) returns
|
|
8716
|
+
* `null` and the caller falls back to the flat-capacity branch. Logged
|
|
8717
|
+
* at debug so a real permissions misconfiguration is still visible
|
|
8718
|
+
* under `--verbose`.
|
|
8719
|
+
*
|
|
8720
|
+
* @param tableName DynamoDB table name (the `physicalId`).
|
|
8721
|
+
* @param scalableDimension `'dynamodb:table:WriteCapacityUnits'` or
|
|
8722
|
+
* `'dynamodb:table:ReadCapacityUnits'`.
|
|
8723
|
+
* @param client Pre-built region-scoped autoscaling client. Defaults to
|
|
8724
|
+
* a fresh client in the local region — pass an explicit client when
|
|
8725
|
+
* reading from a cross-region replica.
|
|
8726
|
+
*/
|
|
8727
|
+
async readAutoScalingSettings(tableName, scalableDimension, client) {
|
|
8728
|
+
try {
|
|
8729
|
+
const asClient = client ?? new ApplicationAutoScalingClient({ region: await this.dynamoDBClient.config.region() ?? "" });
|
|
8730
|
+
const targets = (await asClient.send(new DescribeScalableTargetsCommand({
|
|
8731
|
+
ServiceNamespace: "dynamodb",
|
|
8732
|
+
ResourceIds: [`table/${tableName}`],
|
|
8733
|
+
ScalableDimension: scalableDimension
|
|
8734
|
+
}))).ScalableTargets ?? [];
|
|
8735
|
+
if (targets.length === 0) return null;
|
|
8736
|
+
const target = targets[0];
|
|
8737
|
+
if (target.MinCapacity === void 0 || target.MaxCapacity === void 0) return null;
|
|
8738
|
+
const targetTracking = ((await asClient.send(new DescribeScalingPoliciesCommand({
|
|
8648
8739
|
ServiceNamespace: "dynamodb",
|
|
8649
8740
|
ResourceId: `table/${tableName}`,
|
|
8650
|
-
ScalableDimension:
|
|
8651
|
-
}))).ScalingPolicies ?? []).
|
|
8741
|
+
ScalableDimension: scalableDimension
|
|
8742
|
+
}))).ScalingPolicies ?? []).find((p) => p.PolicyType === "TargetTrackingScaling");
|
|
8743
|
+
if (!targetTracking) return null;
|
|
8744
|
+
const cfg = targetTracking.TargetTrackingScalingPolicyConfiguration;
|
|
8745
|
+
if (!cfg || cfg.TargetValue === void 0) return null;
|
|
8746
|
+
const tttConfig = { TargetValue: cfg.TargetValue };
|
|
8747
|
+
if (cfg.DisableScaleIn !== void 0) tttConfig["DisableScaleIn"] = cfg.DisableScaleIn;
|
|
8748
|
+
if (cfg.ScaleInCooldown !== void 0) tttConfig["ScaleInCooldown"] = cfg.ScaleInCooldown;
|
|
8749
|
+
if (cfg.ScaleOutCooldown !== void 0) tttConfig["ScaleOutCooldown"] = cfg.ScaleOutCooldown;
|
|
8750
|
+
return {
|
|
8751
|
+
MinCapacity: target.MinCapacity,
|
|
8752
|
+
MaxCapacity: target.MaxCapacity,
|
|
8753
|
+
TargetTrackingScalingPolicyConfiguration: tttConfig
|
|
8754
|
+
};
|
|
8652
8755
|
} catch (err) {
|
|
8653
|
-
this.logger.debug(`Could not
|
|
8654
|
-
return
|
|
8756
|
+
this.logger.debug(`Could not read application-autoscaling settings for ${tableName} (${scalableDimension}): ${err instanceof Error ? err.message : String(err)}`);
|
|
8757
|
+
return null;
|
|
8655
8758
|
}
|
|
8656
8759
|
}
|
|
8657
8760
|
/**
|
|
@@ -8659,13 +8762,17 @@ var DynamoDBGlobalTableProvider = class {
|
|
|
8659
8762
|
* reverse-map. The drift comparator skips these so a templated value
|
|
8660
8763
|
* doesn't fire guaranteed false drift on every clean run.
|
|
8661
8764
|
*
|
|
8662
|
-
* Issue #389 emptied this list:
|
|
8663
|
-
* - `WriteProvisionedThroughputSettings`
|
|
8664
|
-
*
|
|
8665
|
-
*
|
|
8666
|
-
*
|
|
8667
|
-
*
|
|
8668
|
-
*
|
|
8765
|
+
* Issue #389 + #395 emptied this list:
|
|
8766
|
+
* - `WriteProvisionedThroughputSettings` reverse-maps both the flat
|
|
8767
|
+
* `{WriteCapacityUnits}` shape (no autoscaling) AND the full
|
|
8768
|
+
* `{WriteCapacityAutoScalingSettings}` shape (autoscaling-managed;
|
|
8769
|
+
* recovered from `DescribeScalableTargets` +
|
|
8770
|
+
* `DescribeScalingPolicies`). PAY_PER_REQUEST tables emit `{}`.
|
|
8771
|
+
* - Per-replica `ReadProvisionedThroughputSettings.ReadCapacityAutoScalingSettings`
|
|
8772
|
+
* reverse-maps from a region-scoped application-autoscaling client
|
|
8773
|
+
* for the `dynamodb:table:ReadCapacityUnits` dimension. Non-
|
|
8774
|
+
* autoscaled replicas omit the key (no per-replica flat read
|
|
8775
|
+
* capacity available in `DescribeTable`).
|
|
8669
8776
|
* - `WriteOnDemandThroughputSettings` is reverse-mapped from
|
|
8670
8777
|
* `Table.OnDemandThroughput.MaxWriteRequestUnits`. Always-emit
|
|
8671
8778
|
* `{}` placeholder when AWS reports no override.
|
|
@@ -44576,7 +44683,7 @@ function reorderArgs(argv) {
|
|
|
44576
44683
|
*/
|
|
44577
44684
|
async function main() {
|
|
44578
44685
|
const program = new Command();
|
|
44579
|
-
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.
|
|
44686
|
+
program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.107.0");
|
|
44580
44687
|
program.addCommand(createBootstrapCommand());
|
|
44581
44688
|
program.addCommand(createSynthCommand());
|
|
44582
44689
|
program.addCommand(createListCommand());
|