feat: add cdk subcommand for CDK app integration#612
Merged
Conversation
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
…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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
delstack cdksubcommand that synthesizes a CDK app and deletes all stacks with dependency resolutione2e/cdk_integration/)Closes #611