Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8a4071c
Migrate to `toolkit-lib`
corymhall Nov 13, 2025
8ae8b4b
chore: scaffold cdk convert core package
corymhall Nov 12, 2025
4960bc5
feat: move core conversion modules and add resource emitter
corymhall Nov 12, 2025
e28c6e5
Add IR types and start intrinsic value adapter
corymhall Nov 12, 2025
f44a6fc
Add initial IR resource emitter
corymhall Nov 12, 2025
9623093
Point tests at core package and fix async staging expectations
corymhall Nov 12, 2025
aca11d7
Add IR intrinsic resolver and StackConverter IR path
corymhall Nov 12, 2025
fe32284
Move converter contracts into core package
corymhall Nov 12, 2025
135117e
feat(cli): add ProgramIR YAML serializer
corymhall Nov 12, 2025
94267c9
fix(app-converter): import attributePropertyName from core
corymhall Nov 12, 2025
826fb05
Wire core re-exports and fix IR stack converter
corymhall Nov 12, 2025
279ed4e
feat(cli): add cdk-to-pulumi prototype
corymhall Nov 13, 2025
1006bf1
Switch to npm workspaces
corymhall Nov 13, 2025
950dfb2
Move normalization into core and normalize IR props
corymhall Nov 13, 2025
4cb6dff
Handle Fn::Sub and other intrinsics in IR resolver
corymhall Nov 13, 2025
42b9d69
Map Ref references to resource ids in IR output
corymhall Nov 13, 2025
095ec11
Resolve CF Ref metadata when emitting IR
corymhall Nov 13, 2025
f49d6b6
Fix YAML dependsOn references
corymhall Nov 13, 2025
a2421ba
Add IR post-processing for CLI output
corymhall Nov 13, 2025
c9ac373
Add --skip-custom
corymhall Nov 13, 2025
927927b
update dependencies
corymhall Nov 13, 2025
59ea06f
Ensure IR YAML uses logical IDs
corymhall Nov 13, 2025
7dce6c1
Fixing some stuff
corymhall Nov 14, 2025
156ae31
Reorganize
corymhall Nov 14, 2025
04ed9cf
Add stage-aware assembly loading
corymhall Nov 14, 2025
b2d9c7e
Add stack import/output handling
corymhall Nov 14, 2025
41aead2
Add ServiceDiscovery Classic rewrites
corymhall Nov 14, 2025
0160b29
Fixing build
corymhall Nov 17, 2025
ed38b81
Fix scripts
corymhall Nov 17, 2025
acd2b8e
Add conversion report CLI flags
corymhall Nov 17, 2025
6378d87
Add conversion report builder and CLI output
corymhall Nov 17, 2025
0404fa2
Document CLI workflow and conversion report
corymhall Nov 17, 2025
2edcba7
Update nodejs version in CI
corymhall Nov 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.x
registry-url: https://registry.npmjs.org
- name: Install Yarn
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.x
registry-url: https://registry.npmjs.org
- name: Install Yarn
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.x
registry-url: https://registry.npmjs.org
- name: Install Go
uses: actions/setup-go@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.x
registry-url: https://registry.npmjs.org
- name: Install Yarn
run: curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.x
registry-url: https://registry.npmjs.org
- name: Install Yarn
run: curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.13.0
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,17 @@ dist
test-reports/
lib/

**/cdk.out
**/cdk*.out
**/cdk.context.json

# direnv
.envrc

# Emacs
.dir-locals.el

.p
import.json
cdk-to-pulumi
Pulumi.yaml
Pulumi-*.yaml
26 changes: 26 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Agent Handoff

Welcome! To continue the CDK-to-Pulumi CLI prototype:

1. Read `spec.md` for the full implementation plan and TODO checklist.
2. Update the checklist in `spec.md` as you complete tasks.
3. Keep this file up to date if the handoff process changes.

Thanks and good luck!

## Status Updates

- See `spec.md` for the authoritative implementation plan, checklist, and latest status.
- Remember to commit frequently as you land logical chunks so handoffs stay easy to follow.

## CLI Prototype Workflow

- The experimental `cdk-to-pulumi` CLI lives under `src/cli/cli-runner.ts` and is also exposed via `./bin/cdk-to-pulumi`.
- Usage pattern:
1. Synthesize the target CDK app so `cdk.out/` exists.
2. Run `npx ts-node src/cli/cli-runner.ts --assembly ./cdk.out --out dist/Pulumi.yaml` (or the bin script) to emit Pulumi YAML. Include `--stage`/`--stacks`/`--skip-custom` as needed.
3. The CLI writes `<outFile>.report.json` unless `--no-report` is passed; the report captures per-stack stats, skipped resources, AWS Classic fallbacks, and fan-out rewrites.
- Targeted tests:
- `npm test -- cli-runner` covers argument parsing + CLI plumbing.
- `npm test -- conversion-report` covers the report builder.
- After landing CLI changes, update `spec.md` checklist and keep this file in sync with any workflow adjustments.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
.PHONY: renovate
renovate:
VERSION=$(shell cat package.json | jq -r '.devDependencies["@pulumi/aws-native"]'); \
curl -L https://raw.githubusercontent.com/pulumi/pulumi-aws-native/refs/tags/v$${VERSION}/provider/cmd/pulumi-resource-aws-native/metadata.json -o schemas/aws-native-metadata.json

curl -L https://raw.githubusercontent.com/pulumi/pulumi-aws-native/refs/tags/v$${VERSION}/provider/cmd/pulumi-resource-aws-native/metadata.json -o packages/@pulumi/cdk-convert-core/schemas/aws-native-metadata.json
53 changes: 47 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,48 @@ Pulumi CDK does not support native cross stack references. Instead, you can
convert a value to a Pulumi Output in order to reference the value in a separate
stack.

## CDK-to-Pulumi CLI Prototype

This repo also ships an experimental CLI named `cdk-to-pulumi` that converts an already synthesized CDK assembly (a `cdk.out` folder) into a Pulumi YAML program.

### Running the CLI

1. Make sure you have synthesized your CDK app (for example, by running `cdk synth` so that `cdk.out/` exists).
2. From the repo root, run either the Node-based entrypoint or the bundled binary:

```bash
# From source
npx ts-node src/cli/cli-runner.ts --assembly ./cdk.out --out dist/Pulumi.yaml

# Or using the bin script
./bin/cdk-to-pulumi --assembly ./cdk.out --out dist/Pulumi.yaml
```

Important flags:

- `--assembly <path>`: Required. Points at the CDK `cdk.out` directory (or nested stage directory when used with `--stage`).
- `--out <file>`: Pulumi YAML destination. Defaults to `Pulumi.yaml` in the current directory.
- `--report <file>` / `--no-report`: Controls the conversion report JSON output. By default the CLI writes `<outFile>.report.json` next to the YAML. Use `--no-report` to disable or `--report` to override the path.
- `--stage <name>`: Restrict conversion to a single nested cloud assembly/stage.
- `--stacks <name1,name2>`: Only emit the listed stack artifacts.
- `--skip-custom`: Drop CloudFormation custom resources that would otherwise require the CDK bootstrap bucket emulator.

The CLI writes both the Pulumi YAML and, unless disabled, a structured report describing what happened during conversion. The report captures:

- Per-stack counts (original CFN resource count vs emitted Pulumi resources).
- Each skipped resource (logical ID, type, and reason).
- Cases where we fell back to AWS Classic providers.
- Fan-out rewrites where a single CFN resource expands into multiple Pulumi resources (for example IAM policy attachments).

### Tests

The targeted Jest suites for the CLI live under `tests/cli/`. When updating the CLI or conversion report, run the focused suites:

```bash
npm test -- cli-runner
npm test -- conversion-report
```

## API

See [API Docs](./api-docs/README.md) for more details.
Expand All @@ -1000,15 +1042,15 @@ See [API Docs](./api-docs/README.md) for more details.
Install dependencies, build library, and link for local usage.

```sh
$ yarn install
$ yarn build
$ yarn link
$ npm install
$ npm run build
$ npm link
```

Run unit test:

```sh
$ yarn test
$ npm test

Basic tests
✔ Checking single resource registration (124ms)
Expand All @@ -1027,6 +1069,5 @@ $ yarn test
Run Pulumi examples:

```
$ yarn test-examples
$ npm run test-examples
```

43 changes: 21 additions & 22 deletions adr/cdk-cli-lib.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# CDK CLI Library

Updating to use the
[cdk-cli-lib](https://docs.aws.amazon.com/cdk/api/v2/docs/cli-lib-alpha-readme.html#cloud-assembly-directory-producer)
in order to support CDK Context requires us to make some user-facing API
changes.
[@aws-cdk/toolkit-lib](https://github.com/aws/aws-cdk-cli/tree/main/packages/%40aws-cdk/toolkit-lib)
in order to support CDK Context requires us to make some user-facing API changes.

## Context

Expand Down Expand Up @@ -50,27 +49,26 @@ I’ve included whether it should be possible to use a Pulumi lookup instead.
## Constraints

1. We can use the
[cdk-cli-lib](https://docs.aws.amazon.com/cdk/api/v2/docs/cli-lib-alpha-readme.html#cloud-assembly-directory-producer)
to handle gathering context and handle the multiple passes of executing the
framework, but we have to create the `cdk.App` within an async method.
[@aws-cdk/toolkit-lib](https://github.com/aws/aws-cdk-cli/tree/main/packages/%40aws-cdk/toolkit-lib)
to handle gathering context and perform any required lookups. This library
provides a `Toolkit` with helpers such as `fromAssemblyBuilder` that allow us
to create the `cdk.App` inside an async function with the complete context.

```javascript
class MyProducer implements ICloudAssemblyDirectoryProducer {
async produce(context: Record<string, any>) {
const app = new cdk.App({ context });
const stack = new cdk.Stack(app);
return app.synth().directory;
}
}
const toolkit = new Toolkit();

const source = await toolkit.fromAssemblyBuilder(async ({ context, outdir }) => {
const app = new cdk.App({ context, outdir });
const stack = new cdk.Stack(app);
return app.synth();
});

const cli = AwsCdkCli.fromCloudAssemblyDirectoryProducer(new MyProducer());
await cli.synth();
await toolkit.synth(source);
```

This library requires us to create the `cdk.App` within the `produce` method of
`ICloudAssemblyDirectoryProducer`. This is because the `App` and all constructs
within it must be constructed with the full `context` value. It is not possible
to add context after a construct has been constructed.
This approach requires us to create the `cdk.App` inside the assembly builder,
because the `App` and all constructs must be constructed with the full context
value. It is not possible to add context after a construct has been constructed.

2. Because the constructs can be called multiple times, any Pulumi resources
which are created inside a construct class will also be constructed multiple
Expand Down Expand Up @@ -139,16 +137,17 @@ in core. At a very high level it could look something like this.
```javascript
export class App extends pulumi.ComponentResource {
async initialize() {
const cli = AwsCdkCli.fromCloudAssemblyDirectoryProducer(this);
const toolkit = new Toolkit();
const source = await toolkit.fromAssemblyBuilder(async (props) => this.synthesizeAssembly(props));
// set mocks before we synth
pulumi.runtime.setMocks();
// multiple passes will occur within this. Once we are done
// it will proceed past this.
await cli.synth();
await toolkit.synth(source);
// restore
pulumi.runtime.resetMocks();
// create resources 1 last time with all context available.
await cli.synth();
await toolkit.synth(source);
}
}
```
Expand Down
12 changes: 6 additions & 6 deletions api-docs/Namespace.interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ attribute

| Name | Type | Defined in |
| ------ | ------ | ------ |
| `attributes`? | `object` | [interop.ts:78](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L78) |
| `resource` | `pulumi.Resource` | [interop.ts:77](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L77) |
| `attributes`? | `object` | [src/interop.ts:84](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L84) |
| `resource` | `pulumi.Resource` | [src/interop.ts:83](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L83) |

#### Example

Expand All @@ -37,7 +37,7 @@ return {

#### Defined in

[interop.ts:76](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L76)
[src/interop.ts:82](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L82)

***

Expand All @@ -49,7 +49,7 @@ Use this type if a single CFN resource maps to multiple AWS resources

#### Defined in

[interop.ts:84](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L84)
[src/interop.ts:90](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L90)

***

Expand All @@ -59,7 +59,7 @@ Use this type if a single CFN resource maps to multiple AWS resources

#### Defined in

[interop.ts:86](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L86)
[src/interop.ts:92](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L92)

## Functions

Expand All @@ -86,4 +86,4 @@ The normalized resource properties

#### Defined in

[interop.ts:31](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L31)
[src/interop.ts:30](https://github.com/pulumi/pulumi-cdk/blob/main/src/interop.ts#L30)
Loading
Loading