# aws-cdk-local

> CDK Toolkit for use with LocalStack

Latest version **3.1.0** (published 2026-10-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install aws-cdk-local
pnpm add aws-cdk-local
yarn add aws-cdk-local
bun add aws-cdk-local
```

Provides the command `cdklocal`.

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2026-10-21 |
| First published | 2020-07-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 43.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 306 |
| Author | LocalStack |
| Maintainers | skyrpex, whummer, joe4dev, dominikschubert, srwalker101 |

## Links

- npm: https://www.npmjs.com/package/aws-cdk-local
- Repository: https://github.com/localstack/aws-cdk-local
- Homepage: https://github.com/localstack/aws-cdk-local#readme
- Issues: https://github.com/localstack/aws-cdk-local/issues
- npm.io page: https://npm.io/package/aws-cdk-local

## Dependencies (2)

- [diff](https://npm.io/package/diff.md) ^5.0.0
- [semver](https://npm.io/package/semver.md) ^7.7.4

## Recent versions

- 3.1.0 (latest) — 2026-10-21
- 3.0.4 — 2026-04-01
- 3.0.3 — 2026-03-25
- 3.0.2 — 2026-03-25
- 3.0.1 — 2025-04-22
- 3.0.0 — 2025-04-01
- 2.19.2 — 2025-02-04
- 2.19.1 — 2024-12-20
- 2.19.0 — 2024-11-20
- 2.18.0 — 2023-04-04
- 2.17.0 — 2023-02-15
- 2.16.0 — 2023-01-27
- 2.15.0 — 2022-03-14
- 2.14.0 — 2022-03-02
- 1.65.8 — 2021-08-11
- … 14 more at https://npm.io/package/aws-cdk-local/versions

## README

[![Integration Tests](https://github.com/localstack/aws-cdk-local/actions/workflows/build.yml/badge.svg)](https://github.com/localstack/aws-cdk-local/actions/workflows/build.yml)

# AWS Cloud Development Kit (CDK) for LocalStack

> [!WARNING]
> **`cdklocal` is deprecated. Use `lstk cdk` instead.**
>
> `cdklocal` no longer receives updates.
>
> - Get started with `lstk`, the new LocalStack CLI: [docs.localstack.cloud/.../lstk](https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/)
> - Switch your scripts and CI workflows to `lstk cdk`: [docs.localstack.cloud/.../lstk/migration](https://docs.localstack.cloud/aws/developer-tools/running-localstack/lstk/migration/#infrastructure-as-code)

This project provides a thin wrapper script `cdklocal` for using the [AWS CDK](https://github.com/aws/aws-cdk) library against local APIs provided by [LocalStack](https://localstack.cloud).

**Note:** This project replaces the [old (deprecated) repo](https://github.com/localstack/aws-cdk) which was a fork of the AWS CDK repo. Instead of forking the repo and applying changes, we now simply provide a simple wrapper script `cdklocal` which applies runtime patching. The advantage of the new approach is that you should be able to use arbitrary CDK versions under the cover.

## Quick Installation

The `cdklocal` command line is published as an [npm library](https://www.npmjs.com/package/aws-cdk-local):
```bash
$ npm install -g aws-cdk-local aws-cdk
...
$ cdklocal --version
1.65.5
```

**Note:** Starting with version `1.65.2`, the dependency `aws-cdk` needs to be installed manually
(to decouple the two libraries, and allow using arbitrary versions of `aws-cdk` under the covers).

(Note: Depending on your local setup, you may or may not have to use the global `npm` installation flag `-g` above.)

### Mac OS specific `MODULE_NOT_FOUND` issue
On Mac OS, brew can be used to install AWS CDK, which might result in a `MODULE_NOT_FOUND` error from `cdklocal`.
To resolve this, set the `NODE_PATH` variable pointing to your AWS CDK's `node_module` folder to expand the lookup path for modules.
```bash
$ export NODE_PATH=$NODE_PATH:/opt/homebrew/Cellar/aws-cdk/<CDK_VERSION>/libexec/lib/node_modules
```

## Version support

`cdklocal` supports all installed versions of the node `aws-cdk` package, however some complications are present for `aws-cdk >= 2.177.0`.

For these CDK versions, we remove AWS configuration environment variables like `AWS_PROFILE` from the shell environment before invoking the `cdk` command, and explicitly set `AWS_ENDPOINT_URL` and `AWS_ENDPOINT_URL_S3` to target LocalStack.

1. We do this because other environment variables may lead to a conflicting set of configuration options, where the wrong region is used to target LocalStack, or `cdklocal` tries to deploy into upstream AWS by mistake. If individual configuration variables are needed for the deploy process (e.g. `AWS_REGION`) these configuration variables can be propagated to the `cdk` command by configuring `AWS_ENVAR_ALLOWLIST`, for example: `AWS_ENVAR_ALLOWLIST=AWS_REGION,AWS_DEFAULT_REGION AWS_DEFAULT_REGION=eu-central-1 AWS_REGION=eu-central-1 cdklocal ...`.
2. If you are manually setting `AWS_ENDPOINT_URL`, the new value will continue to be read from the environment, however `AWS_ENDPOINT_URL_S3` _must_ also be set and should include a `.s3.` component to ensure we correctly detect S3 requests.

## Configurations

The following environment variables can be configured:

* `AWS_ENDPOINT_URL`: The endpoint URL to connect to (combination of `USE_SSL`/`LOCALSTACK_HOSTNAME`/`EDGE_PORT` below)
* `AWS_ENDPOINT_URL_S3`: The endpoint URL to connect to (combination of `USE_SSL`/`LOCALSTACK_HOSTNAME`/`EDGE_PORT` below) for S3 requests
* `AWS_ENVAR_ALLOWLIST`: Allow specific `AWS_*` environment variables to be used by the CDK
* `AWS_S3_FORCE_PATH_STYLE`: Force path-style S3 URLs (CDK >= 2.177.0 only). Automatically enabled when `AWS_ENDPOINT_URL` hostname contains `.sandbox.`. See [Path-style S3 URLs](#path-style-s3-urls-for-remote-endpoints).
* `EDGE_PORT` (deprecated): Port under which LocalStack edge service is accessible (default: `4566`)
* `LOCALSTACK_HOSTNAME` (deprecated): Target host under which LocalStack edge service is accessible (default: `localhost`)
* `USE_SSL` (deprecated): Whether to use SSL to connect to the LocalStack endpoint, i.e., connect via HTTPS.
* `LAMBDA_MOUNT_CODE`: Whether to use local Lambda code mounting (via setting `__local__` S3 bucket name). Note: may require CDK version <2.14.0 to be fully functional.
* `BUCKET_MARKER_LOCAL`: Magic S3 bucket name for Lambda mount and [hot reloading](https://docs.localstack.cloud/user-guide/tools/lambda-tools/hot-reloading) (default: `__local__`, will default to `hot-reload` in a future release)
* `DISABLE_DEPRECATION_NOTICE`: Set to `1` to hide the deprecation notice

### Path-style S3 URLs for remote endpoints

When deploying with CDK >= 2.177.0 against endpoints whose hostname contains `.sandbox.` (e.g. `*.sandbox.localstack.cloud`), asset uploads to S3 require path-style URLs. The wildcard TLS certificate for these endpoints only covers one subdomain level and cannot match virtual-hosted-style bucket addresses like `<bucket>.abc.sandbox.localstack.cloud`.

`cdklocal` automatically enables path-style S3 when it detects a `.sandbox.` hostname in `AWS_ENDPOINT_URL`. You can also opt in explicitly via `AWS_S3_FORCE_PATH_STYLE=1`.

## Deploying a Sample App

The CDK command line ships with a sample app generator to run a quick test for getting started:
```bash
$ mkdir /tmp/test; cd /tmp/test
$ cdklocal init sample-app --language=javascript
...
```

Make sure that LocalStack is installed and started:
```bash
$ localstack start
```

Then deploy the sample app against the local APIs via the `cdklocal` command line:
```bash
$ cdklocal deploy
...
Do you wish to deploy these changes (y/n)? y
...
Stack ARN:
arn:aws:cloudformation:us-east-1:000000000000:stack/TestStack/e3debc0a-311e-4968-8230-ed78f89cb614
```

Once the deployment is done, you can inspect the created resources via the [`awslocal`](https://github.com/localstack/awscli-local) command line:
```bash
$ awslocal sns list-topics
{
    "Topics": [
        {
            "TopicArn": "arn:aws:sns:us-east-1:000000000000:TestStack-TestTopic339EC197-79F43WWCCS4Z"
        }
    ]
}
```

## Change Log

* 3.1.0: Print a deprecation notice that points to `lstk cdk`
* 3.0.4: Fix asset publishing failures for CDK >= 2.177.0 against remote LocalStack endpoints (e.g. `*.sandbox.localstack.cloud`)
* 3.0.3: Add missing `semver` dependency
* 3.0.2: Add support for `aws-cdk` versions after 2026-03-01 (see https://github.com/aws/aws-cdk-cli/issues/310)
* 3.0.1: Using the `-v`/`--version` flag prints the cdklocal version and the version of the underlying `aws-cdk` package (if possible)
* 3.0.0: Sanitise environment of configuration environment variables before deployment
* 2.19.2: Fix SDK compatibility with aws-cdk versions >= 2.177.0
* 2.19.1: Fix SDK compatibility with older CDK versions; Fix patched bucket location in TemplateURL
* 2.19.0: Add support for aws-cdk versions >= `2.167.0`
* 2.18.1: Throw better exception if `aws-cdk` not found
* 2.18.0: Add support for AWS_ENDPOINT_URL, USE_SSL, and BUCKET_MARKER_LOCAL configurations
* 2.17.0: Fix IPv4 fallback check to prevent IPv6 connection issue with `localhost` on macOS
* 2.16.0: Add check to prevent IPv6 connection issue with `localhost` on MacOS
* 2.15.0: Fix issue with undefined BUCKET_NAME_OUTPUT variable; add CI build and eslint config
* 2.14.0: Add switches in patches to accommodate new esbuild packaging mechanism in CDK v2.14.0+
* 1.65.7: Add switch that checks for asset existence before symlinking assets; fix parsing fetched template body for JSON/YAML formats; add missing dependency to "diff" package
* 1.65.6: Create symlinks to Lambda assets to enable persistent code mounting of Lambdas on "cdklocal synth"
* 1.65.5: Add support for `LAMBDA_MOUNT_CODE` config to enable local Lambda code mounting
* 1.65.4: Add support for large stacks by patching bucketUrl for ToolkitInfo
* 1.65.2: Patch missing getPromise() in forceCredentialRetrieval; remove aws-cdk from npm dependencies
* 1.65.1: Override BucketURL to use path style addressing
* 1.65.0: Initial release

## License

The AWS CDK is distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

---
_Source: https://npm.io/package/aws-cdk-local · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
