Enforce AWS CDK security and compliance controls with cdk-nag. Use when adding rule packs, triaging findings, writing justified suppressions, integrating checks in CI/CD, or preventing insecure infrastructure patterns in CDK stacks.
Overall
score
100%
Does it follow best practices?
Validation for skill structure
Use this skill when CDK infrastructure must be validated against security/compliance guardrails.
Do not use this skill for Terraform-only repositories without AWS CDK constructs.
npm install --save-dev cdk-nagExpected result: cdk-nag dependency available for CDK app.
npx cdk synthExpected result: nag findings shown during synthesis.
npx cdk synth MyStackExpected result: targeted findings for the selected stack.
npm test && npx cdk synthExpected result: failing status when tests or nag checks fail.
sh skills/skill-quality-auditor/scripts/evaluate.sh cdk-nag --jsonExpected result: updated skill score and grade.
import { App, Aspects } from 'aws-cdk-lib';
import { AwsSolutionsChecks } from 'cdk-nag';
const app = new App();
// Apply the AWS Solutions rule pack to every stack in the app
Aspects.of(app).add(new AwsSolutionsChecks({ verbose: true }));Expected result: all stacks synthesized with the AwsSolutionsChecks pack applied; findings printed to stdout during cdk synth.
import { NagSuppressions } from 'cdk-nag';
// Suppress a single rule on a specific construct, not the whole stack
NagSuppressions.addResourceSuppressions(
myBucket,
[
{
id: 'AwsSolutions-S1',
reason:
'Server access logging disabled intentionally: bucket stores only ephemeral build artifacts ' +
'with no PII; access is restricted to the CI role via bucket policy. ' +
'Risk accepted and documented in ADR-042.',
},
],
);Expected result: only myBucket is exempted from AwsSolutions-S1; all other resources and rules remain enforced.
WHY: Unjustified suppressions hide unresolved risk.
BAD: reason: "false positive" with no evidence.
GOOD: reason: "resource isolated in private subnet; compensating controls documented".
Consequence: Audit posture weakens and real issues stay unresolved.
WHY: Broad suppressions mask unrelated violations.
BAD: Suppress an entire rule for every resource in a stack. GOOD: Scope suppression to exact resource and finding.
Consequence: New regressions pass undetected.
WHY: Late checks create expensive rework.
BAD: Add strict rule packs only before deployment. GOOD: Run target rule packs continuously in feature branches.
Consequence: Security defects are found too late.
WHY: Repeated failures indicate systemic misconfiguration.
BAD: Re-run pipeline until flake passes without remediation. GOOD: Fix root cause or add justified suppression once.
Consequence: Compliance debt accumulates quickly.
references/implementation-guide.mdreferences/rule-packs.mdreferences/suppression-guide.mdreferences/troubleshooting.mdreferences/rule-evolution.mdreferences/integration-patterns.mdInstall with Tessl CLI
npx tessl i pantheon-ai/cdk-nag@0.1.1