Skip to content

feat: add cdk subcommand for CDK app integration#612

Merged
go-to-k merged 19 commits intomainfrom
feat/cdk-subcommand
Mar 30, 2026
Merged

feat: add cdk subcommand for CDK app integration#612
go-to-k merged 19 commits intomainfrom
feat/cdk-subcommand

Conversation

@go-to-k
Copy link
Copy Markdown
Owner

@go-to-k go-to-k commented Mar 28, 2026

Summary

  • Add delstack cdk subcommand that synthesizes a CDK app and deletes all stacks with dependency resolution
  • Support cross-region deletion with automatic region detection from Cloud Assembly manifest
  • Add E2E test environment (e2e/cdk_integration/)

Closes #611

Add `delstack cdk` subcommand that synthesizes a CDK app and deletes
all stacks with dependency resolution, including cross-region stacks.

- Synthesize via `cdk synth` subprocess or read existing cdk.out (`-a`)
- Parse Cloud Assembly manifest.json for stack discovery
- Auto-detect regions from manifest environment field
- Support cross-region deletion with dependency ordering
- CDK-specific flags: `-a` (app path), `-c` (context values)
- All existing global flags (`-f`, `-y`, `-s`, `-i`, etc.) work with subcommand
- Add E2E test environment (e2e/cdk_integration/)
- Update README, CONTRIBUTING.md, Makefile

Closes #611
go-to-k added 18 commits March 29, 2026 04:06
…etain E2E tests

- Redefine shared flags (-s, -p, -r, -i, -f, -y, -n) on the cdk
  subcommand so they work after the subcommand name (urfave/cli v2
  does not propagate global flags to subcommands)
- Add cross-region E2E test (e2e/cdk_cross_region/): EdgeStack in
  us-east-1 + MainStack in ap-northeast-1 with dependency
- Add RETAIN_MODE support to cdk_integration E2E for testing -f flag
- Add e2e_cdk_integration_retain and e2e_cdk_cross_region Makefile targets
- Move CDK integration to last in README Features list
Previously, regions were deleted sequentially even when there were no
cross-region dependencies. Now uses errgroup to delete all regions
concurrently.
- Add cdk, cdk-app, cdk-context inputs to action.yml
- Add CDK mode section to GitHub Actions README docs
- Use npx cdk instead of cdk for synthesis (no global install required)
- Add -i and -s mutual exclusion validation to cdk subcommand
- Fix action.yml stacks option position (delstack cdk $stacks before $cdk_app)
- Refactor cdk.go: extract deletion logic to cdk_deleter.go
- Restructure README CDK section: usage at top, details below
- Add RETAIN_MODE support to cross-region e2e
- Add crossRegionReferences to cross-region e2e CDK app
- Add testgen/e2e retain targets for cdk_integration and cdk_cross_region
- Update CONTRIBUTING.md with all new e2e targets
- Update e2e READMEs with RETAIN documentation
- ParseManifest now recursively parses cdk:cloud-assembly artifacts
  to discover stacks inside CDK Stages (assembly-*/ subdirectories)
- Add unit tests for nested assembly and multiple stages
- Add e2e/cdk_stage/ test environment (2 stages, 2 regions)
- Update Makefile, CONTRIBUTING.md with cdk_stage targets
…CDK Stages

When CDK Stages are used, displayName contains paths like "MyStage/StackA"
which are invalid CloudFormation stack names. The actual stack name is in
properties.stackName.

Stack name resolution priority: properties.stackName > displayName > artifact key

Also fix deploy.go for Stage e2e to use stage glob patterns instead of --all.
- Add all CDK e2e targets to testgen_help and e2e_help in Makefile
- Restructure README: CDK usage at top (How to use), details below
  (CDK Integration Details section with cross-region and Stage docs)
- Fix Stage e2e deploy.go to use stage glob patterns for cdk deploy
…crossRegionReferences)

Pattern A: AddDependency + CFn Export/Import (EdgeStackA -> MainStackA)
Pattern B: crossRegionReferences with SSM (EdgeStackB -> MainStackB)

4 stacks total across 2 regions, testing both CDK cross-region mechanisms.
…lue) + README restructure

- Pattern A now uses AddDependency only (Fn::ImportValue is not supported cross-region)
- Move CDK Integration into How to use as ### subsection
- Remove CDK Stage support section from README (implementation detail)
- Add missing CDK examples to Makefile testgen_help and e2e_help
Same-level stacks across different regions are independent and can be
deleted concurrently. Use errgroup instead of sequential for loop.
Pattern A: EdgeStackA in ap-northeast-1, MainStackA in us-east-1
Pattern B: EdgeStackB in us-east-1, MainStackB in ap-northeast-1

This ensures same-level stacks span both regions, exercising the
errgroup-based parallel region deletion within each dependency level.
Replace level-by-level loop with channel-based dynamic scheduling
(same pattern as existing deleteStacksDynamically). Stacks are started
immediately when their dependencies are satisfied, without waiting for
the entire level to complete.

Example: MainStackA done → EdgeStackA starts immediately, even if
MainStackB is still running.
Skip stacks that don't exist in AWS instead of failing with an error.
This handles the case where cdk.out contains stacks that haven't been
deployed yet.

- Add StackExists method to CloudFormationStackOperator (via DescribeStacks)
- Add filterExistingStacks to cdk.go (operator-based, per-region)
- Add unit tests for StackExists (exists, not found, error)
@go-to-k go-to-k merged commit 5094e89 into main Mar 30, 2026
2 checks passed
@go-to-k go-to-k deleted the feat/cdk-subcommand branch March 30, 2026 05:16
@github-actions github-actions bot mentioned this pull request Mar 30, 2026
@github-actions github-actions bot mentioned this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add cdk subcommand for CDK app integration

1 participant