Check AWS CDK applications or CloudFormation templates for best practices by using cdk-nag rule packs
Created by Arun Donti
Environment: Production | Technologies: DevOps; Security, identity, compliance | Workload: Open-source |
AWS services: AWS CDK |
Summary
This pattern explains how you can use the cdk-nag
You can also use cdk-nag to check your AWS CloudFormation templates by using the cloudformation-include module.
For information about all available packs, see the Rules
Prerequisites and limitations
Prerequisites
An application that uses the AWS CDK
Tools
AWS CDK – Cloud Development Kit (AWS CDK) is a software development framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation.
AWS CloudFormation – AWS CloudFormation helps you model and set up your AWS resources, provision them quickly and consistently, and manage them throughout their lifecycle. You can use a template to describe your resources and their dependencies, and you can launch and configure them together as a stack, instead of managing resources individually. You can manage and provision stacks across multiple AWS accounts and AWS Regions.
Epics
Task | Description | Skills required |
---|---|---|
Learn about cdk-nag. | Navigate to the cdk-nag | App developer |
Install the cdk-nag package in your AWS CDK application. | To use cdk-nag in your AWS CDK application, you must install it first. cdk-nag is available to download from PyPI, npm, NuGet, and Apache Maven. For the latest information about available versions and download locations, see the Readme file | App developer |
Choose your NagPacks. | cdk-nag has different packs of rules called NagPacks. Each NagPack contains rules that conform to a specific standard. For example, the AWS Solutions NagPack contains general best practices, and the NIST 800-53 rev 5 NagPack can help with compliance. You can apply multiple NagPacks to your application, and you can add and remove packs as necessary. For a list of available packs, see the Readme file | App developer |
Integrate cdk-nag into your AWS CDK application. | You can integrate cdk-nag into your application on an applicationwide level, or integrate it into individual stages or stacks in your application. For example, to integrate the AWS Solutions and HIPAA security NagPacks into an AWS CDK v2 TypeScript application on an applicationwide level, you can use the following code:
| App developer |