feat(cdk): add CDK plugin with completion and aliases

Adds a new cdk plugin for the AWS Cloud Development Kit CLI.

- Completion: cached via \cdk --completion zsh\ (same pattern as
  the argocd and helm plugins), stored in \/completions/_cdk
  and refreshed asynchronously on each shell start.
- Aliases: cdkl, cdkls, cdks, cdkd, cdkda, cdkdiff, cdkdes, cdkdesa,
  cdkw, cdkb, cdkdf, cdkdaf, cdkho, cdkdoc, cdkmeta, cdkctx,
  cdkctxr, cdkack.

Closes #11816
This commit is contained in:
SparshGarg999 2026-06-25 17:35:11 +05:30
commit ea4b103ac1
2 changed files with 94 additions and 0 deletions

48
plugins/cdk/README.md Normal file
View file

@ -0,0 +1,48 @@
# CDK plugin
This plugin adds completion support and convenient aliases for the
[AWS Cloud Development Kit (CDK)](https://docs.aws.amazon.com/cdk/latest/guide/home.html) CLI.
To use it, add `cdk` to the plugins array in your zshrc file:
```zsh
plugins=(... cdk)
```
## Requirements
- [Node.js](https://nodejs.org/)
- [aws-cdk](https://www.npmjs.com/package/aws-cdk) installed globally:
```sh
npm install -g aws-cdk
```
## Completion
Completions are generated by running `cdk --completion zsh` and cached in
`$ZSH_CACHE_DIR/completions/_cdk`. The cache is refreshed asynchronously
each time a new shell session starts.
## Aliases
| Alias | Command | Description |
|------------|-----------------------------------------------|--------------------------------------|
| `cdkl` | `cdk list` | List all stacks in the app |
| `cdkls` | `cdk ls` | Alias for `cdk list` |
| `cdks` | `cdk synth` | Synthesize CloudFormation template |
| `cdkd` | `cdk deploy` | Deploy a stack |
| `cdkda` | `cdk deploy --all` | Deploy all stacks |
| `cdkdiff` | `cdk diff` | Show diff against deployed stack |
| `cdkdes` | `cdk destroy` | Destroy a stack |
| `cdkdesa` | `cdk destroy --all` | Destroy all stacks |
| `cdkw` | `cdk watch` | Watch for changes and auto-deploy |
| `cdkb` | `cdk bootstrap` | Bootstrap CDK into an AWS account |
| `cdkdf` | `cdk deploy --require-approval never` | Deploy skipping approval prompts |
| `cdkdaf` | `cdk deploy --all --require-approval never` | Deploy all, skip approval prompts |
| `cdkho` | `cdk deploy --hotswap` | Hotswap deploy (Lambda/ECS/etc.) |
| `cdkdoc` | `cdk doctor` | Check CDK environment setup |
| `cdkmeta` | `cdk metadata` | Display stack metadata |
| `cdkctx` | `cdk context` | View cached context values |
| `cdkctxr` | `cdk context --reset` | Reset all cached context values |
| `cdkack` | `cdk acknowledge` | Acknowledge a CDK notice |

View file

@ -0,0 +1,46 @@
# Autocompletion for the AWS CDK CLI.
#
# AWS CDK supports generating its own zsh completion script via
# `cdk --completion`. This plugin caches that output and refreshes
# it asynchronously on each shell start, following the same pattern
# used by the argocd and helm plugins.
if (( ! $+commands[cdk] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `cdk`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_cdk" ]]; then
typeset -g -A _comps
autoload -Uz _cdk
_comps[cdk]=_cdk
fi
cdk --completion zsh >| "$ZSH_CACHE_DIR/completions/_cdk" &|
# ── Aliases ──────────────────────────────────────────────────────────────────
# Core workflow
alias cdkl='cdk list'
alias cdkls='cdk ls'
alias cdks='cdk synth'
alias cdkd='cdk deploy'
alias cdkda='cdk deploy --all'
alias cdkdiff='cdk diff'
alias cdkdes='cdk destroy'
alias cdkdesa='cdk destroy --all'
alias cdkw='cdk watch'
alias cdkb='cdk bootstrap'
# Faster deploys
alias cdkdf='cdk deploy --require-approval never'
alias cdkdaf='cdk deploy --all --require-approval never'
alias cdkho='cdk deploy --hotswap'
# Metadata / diagnostics
alias cdkdoc='cdk doctor'
alias cdkmeta='cdk metadata'
alias cdkctx='cdk context'
alias cdkctxr='cdk context --reset'
alias cdkack='cdk acknowledge'