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
CDK Nag provides multiple rule packs targeting different compliance frameworks and security standards. Each pack contains specific rules tailored to its compliance domain.
Purpose: AWS Foundational Security Best Practices
Import: import { AwsSolutionsChecks } from 'cdk-nag';
Scope: General AWS security best practices used in AWS Solutions Library
Key Focus Areas:
Common Rules:
AwsSolutions-IAM4: Prevents AWS managed policiesAwsSolutions-IAM5: Restricts wildcard permissionsAwsSolutions-SNS3: Requires SSL for SNS publishersAwsSolutions-S1: Requires S3 access loggingAwsSolutions-EC23: Prevents overly permissive security groupsPurpose: Healthcare compliance requirements
Import: import { HipaaSecurityChecks } from 'cdk-nag';
Scope: Health Insurance Portability and Accountability Act compliance
Key Focus Areas:
Usage Example:
// Healthcare applications
Aspects.of(app).add(new HipaaSecurityChecks());Purpose: Government security standards
Import: import { NIST80053R4Checks, NIST80053R5Checks } from 'cdk-nag';
Scope: National Institute of Standards and Technology security controls
Key Focus Areas:
Usage Example:
// Government/federal applications
Aspects.of(app).add(new NIST80053R5Checks());Purpose: Payment card industry standards
Import: import { PCIDSS321Checks } from 'cdk-nag';
Scope: Payment Card Industry Data Security Standard
Key Focus Areas:
Usage Example:
// Payment processing applications
Aspects.of(app).add(new PCIDSS321Checks());Purpose: Serverless-specific security patterns
Import: import { ServerlessChecks } from 'cdk-nag';
Scope: Security best practices for serverless architectures
Key Focus Areas:
General AWS Applications:
Aspects.of(app).add(new AwsSolutionsChecks());Healthcare Applications:
Aspects.of(app).add(new AwsSolutionsChecks());
Aspects.of(app).add(new HipaaSecurityChecks());Financial Services:
Aspects.of(app).add(new AwsSolutionsChecks());
Aspects.of(app).add(new PCIDSS321Checks());Government/Federal:
Aspects.of(app).add(new AwsSolutionsChecks());
Aspects.of(app).add(new NIST80053R5Checks());Serverless Applications:
Aspects.of(app).add(new AwsSolutionsChecks());
Aspects.of(app).add(new ServerlessChecks());const environment = process.env.ENVIRONMENT || 'dev';
const complianceRequirements =
process.env.COMPLIANCE_REQUIREMENTS?.split(',') || [];
// Always apply foundational security
Aspects.of(app).add(new AwsSolutionsChecks());
// Environment-specific compliance
if (environment === 'production') {
if (complianceRequirements.includes('HIPAA')) {
Aspects.of(app).add(new HipaaSecurityChecks());
}
if (complianceRequirements.includes('PCI')) {
Aspects.of(app).add(new PCIDSS321Checks());
}
if (complianceRequirements.includes('NIST')) {
Aspects.of(app).add(new NIST80053R5Checks());
}
}These packs work well together and provide layered security:
Some rules may overlap between packs. This is generally not problematic as:
Multiple rule packs increase synthesis time:
Consider environment-specific application for production deployments.
For specialized compliance requirements, you can create custom rule packs:
import { NagPack, NagPackProps } from 'cdk-nag';
export class CustomComplianceChecks extends NagPack {
constructor(props?: NagPackProps) {
super(props);
this.packName = 'CustomCompliance';
}
visit(node: IConstruct): void {
// Implement custom rules
}
}Each rule pack maintains detailed documentation:
Refer to the official RULES.md for complete rule listings and details.
Install with Tessl CLI
npx tessl i pantheon-ai/cdk-nag@0.1.1