A VS Code extension that runs cdk-nag against your AWS CDK project from inside the editor. It synthesises your CDK app, applies the configured rule packs to the resulting CloudFormation template, and surfaces findings as diagnostics in the Problems panel.
- 🛡️ Multiple compliance standards:
AwsSolutionsChecks,HIPAA.SecurityChecks,NIST.800-53.R4Checks,NIST.800-53.R5Checks,PCI.DSS.321Checks, andServerlessChecks— any subset can be enabled via settings. - ⚙️ Custom rules: Add project-specific rules targeted at CloudFormation resource types; conditions are evaluated in a sandboxed Node
vmcontext with no access torequire/process/globals and a hard 500 ms timeout. - 🔍 On-demand validation: Commands to validate the current file or the full workspace from the Command Palette.
- 🎯 Diagnostics integration: Findings appear in the Problems panel, anchored to the matching resource declaration in your source when a single-line match is available.
- 🔒 No shell execution: The underlying runner is invoked with
spawn(shell disabled); all template/config data is passed via a JSON input file — no user input is ever interpolated into a shell string.
- Open VS Code
- Press
Ctrl+P(Windows/Linux) orCmd+P(Mac) - Paste the following command:
ext install alphacrack.cdk-nag-validator - Press Enter
- Visual Studio Code 1.96.2 or higher
- Node.js 18.x, 20.x, or 22.x
- An AWS CDK project with a
cdk.jsonandaws-cdk-lib+cdk-naginstalled as project dependencies (the extension resolvescdk-nagfrom your workspace'snode_modules) - AWS CDK CLI available on PATH (the extension runs
cdk synth --no-stagingin your workspace)
All actions are triggered manually from the Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
| Command | Description |
|---|---|
CDK NAG: Validate Current File |
Synthesises the workspace, runs the configured rule packs + custom rules, and surfaces findings mapped to the active file. |
CDK NAG: Validate Workspace |
Same as above but scopes diagnostic mapping across all *.ts files. |
CDK NAG: Configure Rules |
Interactive picker to enable rule packs and add custom rules. |
Note: The
cdkNagValidator.autoValidatesetting is declared but not yet wired up — validation today is manual. See backlog item M1.
Access settings through VS Code's settings panel or settings.json:
{
"cdkNagValidator.enabledRulePacks": ["AwsSolutionsChecks"],
"cdkNagValidator.customRules": [],
"cdkNagValidator.autoInstall": false
}Available rule packs:
AwsSolutionsChecksHIPAA.SecurityChecksNIST.800-53.R4ChecksNIST.800-53.R5ChecksPCI.DSS.321ChecksServerlessChecks
cdkNagValidator.autoInstall (default false) is an opt-in switch; when enabled, the extension runs npm install aws-cdk aws-cdk-lib cdk-nag yaml --save-dev in your workspace before each validation. Most projects should leave this off and manage these as project deps themselves.
- Node.js 18.x, 20.x, or 22.x
- npm 9.x or higher
- VS Code 1.96.2 or higher
-
Clone the repository:
git clone https://github.com/alphacrack/cdk-nag-extension.git cd cdk-nag-extension -
Install dependencies:
npm install
-
Build the extension:
npm run compile
-
Run tests:
npm test # sandbox + unit (node:test) npm run test:jest # Jest unit tests npm run test:integration # spawns VS Code, checks activation
- Open the project in VS Code
- Press F5 to start debugging
- A new VS Code window will open with the extension loaded
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a list of changes in each version.