@go-to-k/cdkd 0.207.6 → 0.209.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/README.md CHANGED
@@ -59,7 +59,7 @@ Reproduce the first two with `./tests/benchmark/run-benchmark.sh all`. See [test
59
59
  - **Rollback on failure**: When a deploy errors mid-stack, cdkd rolls back the resources it just created so the stack state stays consistent (CloudFormation parity — but cdkd does this without round-tripping through CFn). Pass `cdkd deploy --no-rollback` to skip rollback and keep the partial state for Terraform-style inspection / repair. See [Rollback behavior](#rollback-behavior).
60
60
  - **`--no-wait` for async resources**: Skip the multi-minute wait on CloudFront / RDS / ElastiCache / NAT Gateway and return as soon as the create call returns (CloudFormation always blocks)
61
61
  - **VPC route DependsOn relaxation (on by default)**: Drop CDK-injected defensive `DependsOn` edges from VPC Lambdas onto private-subnet routes so `CloudFront::Distribution` and `Lambda::Url` start their ~3-min propagation in parallel with NAT Gateway stabilization (~50% faster on VPC + Lambda + CloudFront stacks). Pass `--no-aggressive-vpc-parallel` to opt out.
62
- - **Local execution** (`cdkd local invoke` / `start-api` / `run-task` / `start-service` / `invoke-agentcore`): run Lambdas, API Gateway routes, ECS tasks, long-running ECS services, and Bedrock AgentCore Runtimes from your CDK code via Docker. All AWS Lambda runtimes, container Lambdas, REST v1 / HTTP v2 / Function URL routes, Service Connect / Cloud Map, AgentCore HTTP / MCP / A2A / AGUI / WebSocket protocols. Works for both `cdkd deploy`-managed (`--from-state`) AND `cdk deploy`-managed (`--from-cfn-stack`) stacks. See [Local execution](#local-execution).
62
+ - **Local execution** (`cdkd local invoke` / `start-api` / `run-task` / `start-service` / `start-alb` / `start-cloudfront` / `invoke-agentcore` / `start-agentcore`): run Lambdas, API Gateway routes, ECS tasks, long-running ECS services, CloudFront distributions, and Bedrock AgentCore Runtimes from your CDK code. All AWS Lambda runtimes, container Lambdas, REST v1 / HTTP v2 / Function URL routes, Service Connect / Cloud Map, AgentCore HTTP / MCP / A2A / AGUI / WebSocket protocols (one-shot `invoke-agentcore` and long-running `/ws` serve via `start-agentcore`). The Docker-backed commands work for both `cdkd deploy`-managed (`--from-state`) AND `cdk deploy`-managed (`--from-cfn-stack`) stacks; `start-cloudfront` serves the viewer-request -> S3 / Lambda Function URL origin -> viewer-response pipeline (CloudFront-Functions + S3-only distributions run in-process with no Docker). See [Local execution](#local-execution).
63
63
  - **Bidirectional CloudFormation migration**: `cdkd import --migrate-from-cloudformation` adopts existing CFn stacks (including `cdk deploy`-managed) into cdkd state without re-creating resources; `cdkd export` hands a cdkd stack back to CloudFormation when production-ready. See [Importing](#importing-existing-resources) / [Exporting](#exporting-a-stack-back-to-cloudformation).
64
64
 
65
65
  > **Note**: Resource types not covered by either SDK Providers or Cloud Control API cannot be deployed with cdkd. Deployment fails with a clear error message naming the type + a 1-click issue link.
@@ -242,13 +242,19 @@ maintain, no `cdk synth | sam ...` round-trip.
242
242
  | `cdkd local run-task <target>` | ECS RunTask — every container in a task definition started on a per-task docker network |
243
243
  | `cdkd local start-service <target>` | Long-running ECS Service emulator — `DesiredCount` replicas with restart-on-exit (no local load balancer in v1) |
244
244
  | `cdkd local invoke-agentcore <target>` | One-shot Bedrock AgentCore Runtime invoke (HTTP `/invocations` / MCP `/mcp` / A2A `/a2a` / AGUI / WebSocket `--ws`) |
245
+ | `cdkd local start-agentcore [target]` | Long-running serve of a Bedrock AgentCore Runtime's bidirectional `/ws` WebSocket (HTTP / AGUI), fronted by a host bridge that injects the session-id / Authorization a header-less browser client cannot set |
245
246
  | `cdkd local start-alb <targets...>` | Long-running local ALB front-door (HTTP + HTTPS listeners, path / host / header / weighted / redirect / fixed-response routing, authenticate-cognito / authenticate-oidc) for ECS / Lambda backing services |
246
-
247
- Requires Docker. Pass `--from-state` (cdkd-deployed) or
248
- `--from-cfn-stack` (cdk-deployed / CFn-managed) to substitute deployed
249
- physical IDs into intrinsic-valued env vars / secrets / image URIs;
250
- without either, intrinsic values are dropped with a per-key warning
251
- (matches `sam local *`). The two flags are mutually exclusive.
247
+ | `cdkd local start-cloudfront [target]` | Long-running local CloudFront distribution — viewer-request -> S3 / Lambda Function URL origin -> viewer-response pipeline, CloudFront Functions run in-process (Function URL origins use Docker/RIE) |
248
+
249
+ The Docker-backed commands above require Docker. Pass `--from-state`
250
+ (cdkd-deployed) or `--from-cfn-stack` (cdk-deployed / CFn-managed) to
251
+ substitute deployed physical IDs into intrinsic-valued env vars /
252
+ secrets / image URIs; without either, intrinsic values are dropped with
253
+ a per-key warning (matches `sam local *`). The two flags are mutually
254
+ exclusive. `start-cloudfront` is the partial exception: a
255
+ CloudFront-Functions + S3-origin distribution serves entirely in-process
256
+ (no Docker), and it carries cdk-local's `--from-cfn-stack` but not cdkd's
257
+ `--from-state` (its factory lacks the state-provider seam — issue #766).
252
258
 
253
259
  ### `local invoke`
254
260
 
@@ -328,6 +334,28 @@ interpreted-handler source edits go through the bind-mount fast path
328
334
  (no rebuild); Dockerfile / dependency / compiled-source edits fall
329
335
  through to a rebuild + atomic front-door pool swap.
330
336
 
337
+ ### `local start-cloudfront`
338
+
339
+ ```bash
340
+ cdkd local start-cloudfront # interactive picker
341
+ cdkd local start-cloudfront MyStack/MyDistribution # name the distribution
342
+ cdkd local start-cloudfront MyStack/MyDistribution --watch # re-synth + swap on edit
343
+ cdkd local start-cloudfront MyStack/MyDistribution --tls # real HTTPS termination
344
+ ```
345
+
346
+ Serves a CloudFront distribution's **viewer-request -> S3 origin ->
347
+ viewer-response** pipeline locally so a routing-function change is
348
+ verifiable in seconds instead of a deploy round-trip. The distribution's
349
+ `AWS::CloudFront::Function`s (URL rewrites, trailing-slash normalization,
350
+ SPA fallback, header tweaks) run in-process in a `node:vm` sandbox; the
351
+ S3 origin content is the `BucketDeployment` source asset resolved out of
352
+ the cloud assembly, served with `DefaultRootObject` and
353
+ `CustomErrorResponses`. Path patterns route across the default + ordered
354
+ cache behaviors. Pure-local: no Docker, no AWS call — `--watch` is just
355
+ re-synth + an in-memory routing-model swap. S3 origins only (custom /
356
+ Lambda@Edge origins are warn-and-skip); `--origin <id>=<dir>` points an
357
+ origin at a local directory when `BucketDeployment` resolution can't.
358
+
331
359
  See **[docs/local-emulation.md](docs/local-emulation.md)** for the
332
360
  full reference — runtimes, target resolution, every flag, integration
333
361
  and authorizer detail, route precedence, container pool, networking,
package/dist/cli.js CHANGED
@@ -61,7 +61,7 @@ import { CreateVectorBucketCommand, DeleteIndexCommand, DeleteVectorBucketComman
61
61
  import { CreateNamespaceCommand, CreateTableBucketCommand, CreateTableCommand as CreateTableCommand$2, DeleteNamespaceCommand as DeleteNamespaceCommand$1, DeleteTableBucketCommand, DeleteTableCommand as DeleteTableCommand$2, GetTableBucketCommand, GetTableCommand as GetTableCommand$1, ListNamespacesCommand as ListNamespacesCommand$1, ListTableBucketsCommand, ListTablesCommand as ListTablesCommand$1, ListTagsForResourceCommand as ListTagsForResourceCommand$19, NotFoundException as NotFoundException$5, S3TablesClient, TagResourceCommand as TagResourceCommand$16, UntagResourceCommand as UntagResourceCommand$15 } from "@aws-sdk/client-s3tables";
62
62
  import { AttachLoadBalancerTargetGroupsCommand, AttachLoadBalancersCommand, AttachTrafficSourcesCommand, AutoScalingClient, CreateAutoScalingGroupCommand, CreateOrUpdateTagsCommand, DeleteAutoScalingGroupCommand, DeleteLifecycleHookCommand, DeleteNotificationConfigurationCommand, DeleteTagsCommand as DeleteTagsCommand$1, DescribeAutoScalingGroupsCommand, DescribeLifecycleHooksCommand, DescribeNotificationConfigurationsCommand, DescribeTrafficSourcesCommand, DetachLoadBalancerTargetGroupsCommand, DetachLoadBalancersCommand, DetachTrafficSourcesCommand, DisableMetricsCollectionCommand, EnableMetricsCollectionCommand, PutLifecycleHookCommand, PutNotificationConfigurationCommand, UpdateAutoScalingGroupCommand } from "@aws-sdk/client-auto-scaling";
63
63
  import { Document, Pair, Scalar, YAMLMap, YAMLSeq, parse as parse$1, stringify } from "yaml";
64
- import { createLocalStateProvider, getEmbedConfig, isCfnFlagPresent, listTargets, rejectExplicitCfnStackWithMultipleStacks, resolveCfnFallbackRegion, setEmbedConfig, substituteAgainstState, substituteAgainstStateAsync, substituteEnvVarsFromState, substituteEnvVarsFromStateAsync } from "cdk-local";
64
+ import { createLocalStartAgentCoreCommand, createLocalStartCloudFrontCommand, createLocalStateProvider, getEmbedConfig, isCfnFlagPresent, listTargets, rejectExplicitCfnStackWithMultipleStacks, resolveCfnFallbackRegion, setEmbedConfig, substituteAgainstState, substituteAgainstStateAsync, substituteEnvVarsFromState, substituteEnvVarsFromStateAsync } from "cdk-local";
65
65
  import { A2A_CONTAINER_PORT, A2A_PATH, AGENTCORE_A2A_PROTOCOL, AGENTCORE_AGUI_PROTOCOL, AGENTCORE_MCP_PROTOCOL, ConnectionRegistry, EcsTaskResolutionError, HOST_GATEWAY_MIN_VERSION, LocalInvokeBuildError, MCP_CONTAINER_PORT, MCP_PATH, a2aInvokeOnce, addAlbSpecificOptions, addCommonEcsServiceOptions, addStartServiceSpecificOptions, albStrategy, architectureToPlatform, attachAuthorizers, attachStageContext, availableApiIdentifiers, bufferToBody, buildAgentCoreCodeImage, buildCognitoJwksUrl, buildConnectEvent, buildContainerImage, buildCorsConfigByApiId, buildCorsConfigFromCloudFrontChain, buildDisconnectEvent, buildJwksUrlFromIssuer, buildMessageEvent, buildMgmtEndpointEnvUrl, buildStageMap, classifySourceChange, createAuthorizerCache, createFileWatcher, createFileWatcher as createFileWatcher$1, createJwksCache, createWatchPredicates, defaultCredentialsLoader, derivePseudoParametersFromRegion, discoverRoutes, discoverWebSocketApis, downloadAndExtractS3Bundle, filterRoutesByApiIdentifier, groupRoutesByServer, handleConnectionsRequest, invokeAgentCore, invokeAgentCoreWs, materializeLayerFromArn, mcpInvokeOnce, parseConnectionsPath, parseSelectionExpressionPath, pickAgentCoreCandidateStack, pickAgentCoreCandidateStack as pickAgentCoreCandidateStack$1, probeHostGatewaySupport, readMtlsMaterialsFromDisk, resolveAgentCoreTarget, resolveEnvVars, resolveRuntimeCodeMountPath, resolveRuntimeFileExtension, resolveRuntimeImage, resolveSingleTarget, resolveWatchConfig, runEcsServiceEmulator, signAgentCoreInvocation, startApiServer, substituteImagePlaceholders, tryResolveImageFnJoin, verifyJwtViaDiscovery, waitForAgentCorePing } from "cdk-local/internal";
66
66
  import { createServer } from "node:net";
67
67
  import { promisify } from "node:util";
@@ -50787,6 +50787,54 @@ function createLocalInvokeAgentCoreCommand() {
50787
50787
  return cmd;
50788
50788
  }
50789
50789
 
50790
+ //#endregion
50791
+ //#region src/cli/commands/local-start-agentcore.ts
50792
+ /**
50793
+ * `cdkd local start-agentcore <target>` — long-running serve for a Bedrock
50794
+ * AgentCore Runtime's bidirectional `/ws` WebSocket endpoint. Boots the
50795
+ * `AWS::BedrockAgentCore::Runtime` container (same image / env / credential
50796
+ * resolution as `invoke-agentcore`) and fronts its `/ws` endpoint with a host
50797
+ * WebSocket bridge that injects the AgentCore session-id (and `Authorization`
50798
+ * under a `customJwtAuthorizer`) on the container upgrade, so a header-less
50799
+ * client (e.g. a browser) can hold an interactive multi-frame session. HTTP /
50800
+ * AGUI protocols only. The serve counterpart of the single-shot
50801
+ * `cdkd local invoke-agentcore`. Inherited from cdk-local
50802
+ * (go-to-k/cdk-local#420).
50803
+ *
50804
+ * Like `start-cloudfront`, this is a THIN pass-through to cdk-local's factory —
50805
+ * the serve behavior and the `start-agentcore`-only option block (`--port` /
50806
+ * `--host` / `--session-id` / `--bearer-token` / `--no-verify-auth` /
50807
+ * `--env-vars` / `--platform` / `--no-pull` / `--no-build` / `--container-host`
50808
+ * / `--timeout` / `--assume-role` / `--ecr-role-arn` / `--from-cfn-stack` /
50809
+ * `--stack-region`) live in cdk-local's `addStartAgentCoreSpecificOptions` and
50810
+ * are auto-inherited.
50811
+ *
50812
+ * UNLIKE `start-cloudfront`, this command DOES bind deployed state: cdk-local's
50813
+ * factory accepts an `extraStateProviders` option (the same seam the
50814
+ * heavy-wrapper `cdkd local *` commands use), so cdkd threads its S3-backed
50815
+ * `--from-state` factory in via `cdkdExtraStateProviders` and layers the
50816
+ * cdkd-specific `--from-state` / `--state-bucket` / `--state-prefix` flags on
50817
+ * top of cdk-local's inherited `--from-cfn-stack` / `--stack-region` (issue
50818
+ * #766). The factory's internal `createLocalStateProvider` call picks cdkd's
50819
+ * `fromState` factory transparently when `--from-state` is passed.
50820
+ *
50821
+ * The active cdkd embed config is re-handed to the factory so branding stays
50822
+ * cdkd: cdk-local's factory calls `setEmbedConfig(opts.embedConfig)`, and
50823
+ * passing the current config (set once by `createLocalCommand` before the
50824
+ * subcommands are built) keeps it as a no-op re-set rather than a reset back to
50825
+ * cdk-local's `cdkl` defaults.
50826
+ */
50827
+ function createLocalStartAgentCoreCommand$1() {
50828
+ const cmd = createLocalStartAgentCoreCommand({
50829
+ embedConfig: getEmbedConfig(),
50830
+ extraStateProviders: cdkdExtraStateProviders
50831
+ });
50832
+ cmd.addOption(new Option("--from-state", "Read cdkd's S3 state for the target stack and substitute Ref / Fn::GetAtt / Fn::Sub / Fn::ImportValue / Fn::GetStackOutput intrinsics in the AgentCore runtime container image and environment variables. Mutually exclusive with --from-cfn-stack.").default(false));
50833
+ cmd.addOption(new Option("--state-bucket <bucket>", "S3 bucket for --from-state. Falls back to CDKD_STATE_BUCKET env or cdk.json context.cdkd.stateBucket."));
50834
+ cmd.addOption(new Option("--state-prefix <prefix>", "S3 key prefix for --from-state state files.").default("cdkd"));
50835
+ return cmd;
50836
+ }
50837
+
50790
50838
  //#endregion
50791
50839
  //#region src/cli/commands/local-start-alb.ts
50792
50840
  /**
@@ -50804,6 +50852,46 @@ function createLocalStartAlbCommand() {
50804
50852
  return addCommonEcsServiceOptions(cmd);
50805
50853
  }
50806
50854
 
50855
+ //#endregion
50856
+ //#region src/cli/commands/local-start-cloudfront.ts
50857
+ /**
50858
+ * `cdkd local start-cloudfront <distribution>` — serve a CloudFront distribution
50859
+ * locally: its S3 origin content (resolved from the BucketDeployment source in
50860
+ * the cloud assembly) AND its Lambda Function URL origins (the backing Lambda is
50861
+ * run locally via RIE), plus its viewer-request / viewer-response CloudFront
50862
+ * Functions, reproducing the distribution routing so a rewrite / routing change
50863
+ * is verifiable in seconds. Inherited from cdk-local (go-to-k/cdk-local#363,
50864
+ * Lambda Function URL + deployed-S3 origins added in #380).
50865
+ *
50866
+ * Like the `start-agentcore` wrapper, this command is a THIN pass-through to
50867
+ * cdk-local's factory. The serve behavior and the option block (`--port` /
50868
+ * `--host` / `--origin <originId>=<dir>` / `--kvs-file` / `--cache-origin` /
50869
+ * `--no-pull` / `--tls` / `--tls-cert` / `--tls-key` / `--watch`, plus
50870
+ * cdk-local's own `--from-cfn-stack` / `--stack-region` / `--assume-role` for
50871
+ * binding a Function URL origin's backing Lambda + a deployed-S3 origin's bucket
50872
+ * name to deployed state) live in cdk-local and are auto-inherited.
50873
+ *
50874
+ * UNLIKE `start-agentcore` / `start-alb` / `start-service`, this command does
50875
+ * NOT thread cdkd's S3-backed `--from-state` source: cdk-local's
50876
+ * `CreateLocalStartCloudFrontCommandOptions` accepts only `embedConfig`, not the
50877
+ * `extraStateProviders` seam (the factory's internal `createLocalStateProvider`
50878
+ * calls pass no fourth argument). So `--from-state` / `--state-bucket` /
50879
+ * `--state-prefix` and `cdkdExtraStateProviders` threading are intentionally
50880
+ * absent here — start-cloudfront stays exempt from issue #766 until cdk-local
50881
+ * adds `extraStateProviders` to its start-cloudfront factory. Until then the
50882
+ * `--from-cfn-stack` flag (CloudFormation-backed deployed state) is the only
50883
+ * state source on this command.
50884
+ *
50885
+ * The active cdkd embed config is re-handed to the factory so branding stays
50886
+ * cdkd: cdk-local's factory calls `setEmbedConfig(opts.embedConfig)`, and
50887
+ * passing the current config (set once by `createLocalCommand` before the
50888
+ * subcommands are built) keeps it as a no-op re-set rather than a reset back to
50889
+ * cdk-local's `cdkl` defaults.
50890
+ */
50891
+ function createLocalStartCloudFrontCommand$1() {
50892
+ return createLocalStartCloudFrontCommand({ embedConfig: getEmbedConfig() });
50893
+ }
50894
+
50807
50895
  //#endregion
50808
50896
  //#region src/cli/commands/local-invoke.ts
50809
50897
  /**
@@ -51607,7 +51695,9 @@ function createLocalCommand() {
51607
51695
  local.addCommand(createLocalRunTaskCommand());
51608
51696
  local.addCommand(createLocalStartServiceCommand());
51609
51697
  local.addCommand(createLocalInvokeAgentCoreCommand());
51698
+ local.addCommand(createLocalStartAgentCoreCommand$1());
51610
51699
  local.addCommand(createLocalStartAlbCommand());
51700
+ local.addCommand(createLocalStartCloudFrontCommand$1());
51611
51701
  return local;
51612
51702
  }
51613
51703
 
@@ -52746,7 +52836,7 @@ function reorderArgs(argv) {
52746
52836
  async function main() {
52747
52837
  installPipeCloseHandler();
52748
52838
  const program = new Command();
52749
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.207.6");
52839
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.209.0");
52750
52840
  program.addCommand(createBootstrapCommand());
52751
52841
  program.addCommand(createSynthCommand());
52752
52842
  program.addCommand(createListCommand());