skills/infrastructure/aws-cdk/cdk-nag/SKILL.md
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.
npx skillsauth add pantheon-org/tekhne cdk-nagInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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-nag
Expected result: cdk-nag dependency available for CDK app.
npx cdk synth
Expected result: nag findings shown during synthesis.
npx cdk synth MyStack
Expected result: targeted findings for the selected stack.
npm test && npx cdk synth
Expected result: failing status when tests or nag checks fail.
sh skills/agentic-harness/skill-quality-auditor/scripts/evaluate.sh cdk-nag --json
Expected 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.
tools
A skill that produces warnings but no errors.
testing
A well-formed example skill for testing the validator.
development
A skill with code blocks and imperative instructions for testing content and contamination analysis.
tools