Interface for creating a NagPack.
import { NagPackProps } from 'cdk-nag'
const nagPackProps: NagPackProps = { ... }| Name | Type | Description |
|---|---|---|
verbose |
boolean |
Whether or not to enable extended explanatory descriptions on warning, error, and logged ignore messages (default: false). |
writeSuppressionsToCloudFormation |
boolean |
Whether to write acknowledged rules into CfnResource CloudFormation Metadata as cdk_nag: { rules_to_suppress: [...] } for backwards compatibility with v2 audit trail tooling (default: false). |
public readonly verbose: boolean;- Type: boolean
Whether or not to enable extended explanatory descriptions on warning, error, and logged ignore messages (default: false).
public readonly writeSuppressionsToCloudFormation: boolean;- Type: boolean
Whether to write acknowledged rules into CfnResource CloudFormation Metadata as cdk_nag: { rules_to_suppress: [...] } for backwards compatibility with v2 audit trail tooling (default: false).
A single line in a NagReport.
import { NagReportLine } from 'cdk-nag'
const nagReportLine: NagReportLine = { ... }| Name | Type | Description |
|---|---|---|
compliance |
string |
No description. |
resourceId |
string |
No description. |
ruleId |
string |
No description. |
ruleInfo |
string |
No description. |
ruleLevel |
string |
No description. |
public readonly compliance: string;- Type: string
public readonly resourceId: string;- Type: string
public readonly ruleId: string;- Type: string
public readonly ruleInfo: string;- Type: string
public readonly ruleLevel: string;- Type: string
Schema for the NagReport output.
import { NagReportSchema } from 'cdk-nag'
const nagReportSchema: NagReportSchema = { ... }| Name | Type | Description |
|---|---|---|
lines |
NagReportLine[] |
No description. |
public readonly lines: NagReportLine[];- Type: NagReportLine[]
Check Best practices based on AWS Solutions Security Matrix.
import { AwsSolutionsChecks } from 'cdk-nag'
new AwsSolutionsChecks(scope?: IConstruct, props?: NagPackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.IConstruct |
No description. |
props |
NagPackProps |
No description. |
- Type: constructs.IConstruct
- Type: NagPackProps
| Name | Description |
|---|---|
validate |
Entry point called by the CDK validation framework. |
validateScope |
Validate a construct tree directly. |
public validate(context: IPolicyValidationContext): PolicyValidationPluginReportEntry point called by the CDK validation framework.
Requires appConstruct to be present on the context (CDK core change).
For testing or direct invocation, use validateScope(scope).
- Type: aws-cdk-lib.IPolicyValidationContext
public validateScope(scope: IConstruct): PolicyValidationPluginReportValidate a construct tree directly.
This is the primary entry point
for testing and for CDK versions that do not yet provide appConstruct on
IPolicyValidationContext.
- Type: constructs.IConstruct
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the plugin that will be displayed in the validation report. |
readPackName |
string |
No description. |
ruleIds |
string[] |
The list of rule IDs that the plugin will evaluate. |
version |
string |
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0. |
public readonly name: string;- Type: string
The name of the plugin that will be displayed in the validation report.
public readonly readPackName: string;- Type: string
public readonly ruleIds: string[];- Type: string[]
The list of rule IDs that the plugin will evaluate.
Used for analytics purposes.
public readonly version: string;- Type: string
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0.
Check for HIPAA Security compliance.
Based on the HIPAA Security AWS operational best practices: https://docs.aws.amazon.com/config/latest/developerguide/operational-best-practices-for-hipaa_security.html
import { HIPAASecurityChecks } from 'cdk-nag'
new HIPAASecurityChecks(scope?: IConstruct, props?: NagPackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.IConstruct |
No description. |
props |
NagPackProps |
No description. |
- Type: constructs.IConstruct
- Type: NagPackProps
| Name | Description |
|---|---|
validate |
Entry point called by the CDK validation framework. |
validateScope |
Validate a construct tree directly. |
public validate(context: IPolicyValidationContext): PolicyValidationPluginReportEntry point called by the CDK validation framework.
Requires appConstruct to be present on the context (CDK core change).
For testing or direct invocation, use validateScope(scope).
- Type: aws-cdk-lib.IPolicyValidationContext
public validateScope(scope: IConstruct): PolicyValidationPluginReportValidate a construct tree directly.
This is the primary entry point
for testing and for CDK versions that do not yet provide appConstruct on
IPolicyValidationContext.
- Type: constructs.IConstruct
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the plugin that will be displayed in the validation report. |
readPackName |
string |
No description. |
ruleIds |
string[] |
The list of rule IDs that the plugin will evaluate. |
version |
string |
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0. |
public readonly name: string;- Type: string
The name of the plugin that will be displayed in the validation report.
public readonly readPackName: string;- Type: string
public readonly ruleIds: string[];- Type: string[]
The list of rule IDs that the plugin will evaluate.
Used for analytics purposes.
public readonly version: string;- Type: string
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0.
- Implements: aws-cdk-lib.IPolicyValidationPlugin
Base class for all rule packs.
Implements IPolicyValidationPlugin so that
packs are registered via Validations.of(app).addPlugins(new MyPack(app))
instead of Aspects.of(app).add(...).
import { NagPack } from 'cdk-nag'
new NagPack(scope?: IConstruct, props?: NagPackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.IConstruct |
No description. |
props |
NagPackProps |
No description. |
- Type: constructs.IConstruct
- Type: NagPackProps
| Name | Description |
|---|---|
validate |
Entry point called by the CDK validation framework. |
validateScope |
Validate a construct tree directly. |
public validate(context: IPolicyValidationContext): PolicyValidationPluginReportEntry point called by the CDK validation framework.
Requires appConstruct to be present on the context (CDK core change).
For testing or direct invocation, use validateScope(scope).
- Type: aws-cdk-lib.IPolicyValidationContext
public validateScope(scope: IConstruct): PolicyValidationPluginReportValidate a construct tree directly.
This is the primary entry point
for testing and for CDK versions that do not yet provide appConstruct on
IPolicyValidationContext.
- Type: constructs.IConstruct
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the plugin that will be displayed in the validation report. |
readPackName |
string |
No description. |
ruleIds |
string[] |
The list of rule IDs that the plugin will evaluate. |
version |
string |
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0. |
public readonly name: string;- Type: string
The name of the plugin that will be displayed in the validation report.
public readonly readPackName: string;- Type: string
public readonly ruleIds: string[];- Type: string[]
The list of rule IDs that the plugin will evaluate.
Used for analytics purposes.
public readonly version: string;- Type: string
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0.
Helper class with methods for rule creation.
import { NagRules } from 'cdk-nag'
new NagRules()| Name | Type | Description |
|---|
| Name | Description |
|---|---|
resolveIfPrimitive |
Use in cases where a primitive value must be known to pass a rule. |
resolveResourceFromInstrinsic |
No description. |
resolveResourceFromIntrinsic |
Use in cases where a token resolves to an intrinsic function and the referenced resource must be known to pass a rule. |
import { NagRules } from 'cdk-nag'
NagRules.resolveIfPrimitive(node: CfnResource, parameter: any)Use in cases where a primitive value must be known to pass a rule.
https://developer.mozilla.org/en-US/docs/Glossary/Primitive
- Type: aws-cdk-lib.CfnResource
The CfnResource to check.
- Type: any
The value to attempt to resolve.
import { NagRules } from 'cdk-nag'
NagRules.resolveResourceFromInstrinsic(node: CfnResource, parameter: any)- Type: aws-cdk-lib.CfnResource
The CfnResource to check.
- Type: any
The value to attempt to resolve.
import { NagRules } from 'cdk-nag'
NagRules.resolveResourceFromIntrinsic(node: CfnResource, parameter: any)Use in cases where a token resolves to an intrinsic function and the referenced resource must be known to pass a rule.
- Type: aws-cdk-lib.CfnResource
The CfnResource to check.
- Type: any
The value to attempt to resolve.
Check for NIST 800-53 rev 4 compliance.
Based on the NIST 800-53 rev 4 AWS operational best practices: https://docs.aws.amazon.com/config/latest/developerguide/operational-best-practices-for-nist-800-53_rev_4.html
import { NIST80053R4Checks } from 'cdk-nag'
new NIST80053R4Checks(scope?: IConstruct, props?: NagPackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.IConstruct |
No description. |
props |
NagPackProps |
No description. |
- Type: constructs.IConstruct
- Type: NagPackProps
| Name | Description |
|---|---|
validate |
Entry point called by the CDK validation framework. |
validateScope |
Validate a construct tree directly. |
public validate(context: IPolicyValidationContext): PolicyValidationPluginReportEntry point called by the CDK validation framework.
Requires appConstruct to be present on the context (CDK core change).
For testing or direct invocation, use validateScope(scope).
- Type: aws-cdk-lib.IPolicyValidationContext
public validateScope(scope: IConstruct): PolicyValidationPluginReportValidate a construct tree directly.
This is the primary entry point
for testing and for CDK versions that do not yet provide appConstruct on
IPolicyValidationContext.
- Type: constructs.IConstruct
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the plugin that will be displayed in the validation report. |
readPackName |
string |
No description. |
ruleIds |
string[] |
The list of rule IDs that the plugin will evaluate. |
version |
string |
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0. |
public readonly name: string;- Type: string
The name of the plugin that will be displayed in the validation report.
public readonly readPackName: string;- Type: string
public readonly ruleIds: string[];- Type: string[]
The list of rule IDs that the plugin will evaluate.
Used for analytics purposes.
public readonly version: string;- Type: string
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0.
Check for NIST 800-53 rev 5 compliance.
Based on the NIST 800-53 rev 5 AWS operational best practices: https://docs.aws.amazon.com/config/latest/developerguide/operational-best-practices-for-nist-800-53_rev_5.html
import { NIST80053R5Checks } from 'cdk-nag'
new NIST80053R5Checks(scope?: IConstruct, props?: NagPackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.IConstruct |
No description. |
props |
NagPackProps |
No description. |
- Type: constructs.IConstruct
- Type: NagPackProps
| Name | Description |
|---|---|
validate |
Entry point called by the CDK validation framework. |
validateScope |
Validate a construct tree directly. |
public validate(context: IPolicyValidationContext): PolicyValidationPluginReportEntry point called by the CDK validation framework.
Requires appConstruct to be present on the context (CDK core change).
For testing or direct invocation, use validateScope(scope).
- Type: aws-cdk-lib.IPolicyValidationContext
public validateScope(scope: IConstruct): PolicyValidationPluginReportValidate a construct tree directly.
This is the primary entry point
for testing and for CDK versions that do not yet provide appConstruct on
IPolicyValidationContext.
- Type: constructs.IConstruct
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the plugin that will be displayed in the validation report. |
readPackName |
string |
No description. |
ruleIds |
string[] |
The list of rule IDs that the plugin will evaluate. |
version |
string |
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0. |
public readonly name: string;- Type: string
The name of the plugin that will be displayed in the validation report.
public readonly readPackName: string;- Type: string
public readonly ruleIds: string[];- Type: string[]
The list of rule IDs that the plugin will evaluate.
Used for analytics purposes.
public readonly version: string;- Type: string
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0.
Check for PCI DSS 3.2.1 compliance. Based on the PCI DSS 3.2.1 AWS operational best practices: https://docs.aws.amazon.com/config/latest/developerguide/operational-best-practices-for-pci-dss.html.
import { PCIDSS321Checks } from 'cdk-nag'
new PCIDSS321Checks(scope?: IConstruct, props?: NagPackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.IConstruct |
No description. |
props |
NagPackProps |
No description. |
- Type: constructs.IConstruct
- Type: NagPackProps
| Name | Description |
|---|---|
validate |
Entry point called by the CDK validation framework. |
validateScope |
Validate a construct tree directly. |
public validate(context: IPolicyValidationContext): PolicyValidationPluginReportEntry point called by the CDK validation framework.
Requires appConstruct to be present on the context (CDK core change).
For testing or direct invocation, use validateScope(scope).
- Type: aws-cdk-lib.IPolicyValidationContext
public validateScope(scope: IConstruct): PolicyValidationPluginReportValidate a construct tree directly.
This is the primary entry point
for testing and for CDK versions that do not yet provide appConstruct on
IPolicyValidationContext.
- Type: constructs.IConstruct
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the plugin that will be displayed in the validation report. |
readPackName |
string |
No description. |
ruleIds |
string[] |
The list of rule IDs that the plugin will evaluate. |
version |
string |
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0. |
public readonly name: string;- Type: string
The name of the plugin that will be displayed in the validation report.
public readonly readPackName: string;- Type: string
public readonly ruleIds: string[];- Type: string[]
The list of rule IDs that the plugin will evaluate.
Used for analytics purposes.
public readonly version: string;- Type: string
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0.
Serverless Checks are a compilation of rules to validate infrastructure-as-code template against recommended practices.
import { ServerlessChecks } from 'cdk-nag'
new ServerlessChecks(scope?: IConstruct, props?: NagPackProps)| Name | Type | Description |
|---|---|---|
scope |
constructs.IConstruct |
No description. |
props |
NagPackProps |
No description. |
- Type: constructs.IConstruct
- Type: NagPackProps
| Name | Description |
|---|---|
validate |
Entry point called by the CDK validation framework. |
validateScope |
Validate a construct tree directly. |
public validate(context: IPolicyValidationContext): PolicyValidationPluginReportEntry point called by the CDK validation framework.
Requires appConstruct to be present on the context (CDK core change).
For testing or direct invocation, use validateScope(scope).
- Type: aws-cdk-lib.IPolicyValidationContext
public validateScope(scope: IConstruct): PolicyValidationPluginReportValidate a construct tree directly.
This is the primary entry point
for testing and for CDK versions that do not yet provide appConstruct on
IPolicyValidationContext.
- Type: constructs.IConstruct
| Name | Type | Description |
|---|---|---|
name |
string |
The name of the plugin that will be displayed in the validation report. |
readPackName |
string |
No description. |
ruleIds |
string[] |
The list of rule IDs that the plugin will evaluate. |
version |
string |
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0. |
public readonly name: string;- Type: string
The name of the plugin that will be displayed in the validation report.
public readonly readPackName: string;- Type: string
public readonly ruleIds: string[];- Type: string[]
The list of rule IDs that the plugin will evaluate.
Used for analytics purposes.
public readonly version: string;- Type: string
The version of the plugin, following the Semantic Versioning specification (see https://semver.org/). This version is used for analytics purposes, to measure the usage of different plugins and different versions. The value of this property should be kept in sync with the actual version of the software package. If the version is not provided or is not a valid semantic version, it will be reported as 0.0.0.
- Implements: aws-cdk-lib.IAspect
An IAspect that reads acknowledged rules from construct metadata and writes them into the CfnResource's CloudFormation Metadata for audit trail persistence in the synthesized template.
Preserves the v2 cdk_nag
metadata format.
import { WriteNagSuppressionsToCloudFormationAspect } from 'cdk-nag'
new WriteNagSuppressionsToCloudFormationAspect()| Name | Type | Description |
|---|
| Name | Description |
|---|---|
visit |
All aspects can visit an IConstruct. |
public visit(node: IConstruct): voidAll aspects can visit an IConstruct.
- Type: constructs.IConstruct
- Implemented By: IApplyRule
Interface for JSII interoperability for passing parameters and the Rule Callback to.
| Name | Description |
|---|---|
rule |
The callback to the rule. |
public rule(node: CfnResource): NagRuleCompliance | string[]The callback to the rule.
- Type: aws-cdk-lib.CfnResource
The CfnResource to check.
| Name | Type | Description |
|---|---|---|
explanation |
string |
Why the rule exists. |
info |
string |
Why the rule was triggered. |
level |
NagMessageLevel |
The annotations message level to apply to the rule if triggered. |
node |
aws-cdk-lib.CfnResource |
The CfnResource to check. |
ruleSuffixOverride |
string |
Override for the suffix of the Rule ID for this rule. |
public readonly explanation: string;- Type: string
Why the rule exists.
public readonly info: string;- Type: string
Why the rule was triggered.
public readonly level: NagMessageLevel;- Type: NagMessageLevel
The annotations message level to apply to the rule if triggered.
public readonly node: CfnResource;- Type: aws-cdk-lib.CfnResource
The CfnResource to check.
public readonly ruleSuffixOverride: string;- Type: string
Override for the suffix of the Rule ID for this rule.
-
Extends: aws-cdk-lib.IPolicyValidationContext
-
Implemented By: INagValidationContext
Extended validation context that includes the construct tree.
Requires CDK core change to populate appConstruct during plugin validation.
| Name | Type | Description |
|---|---|---|
templatePaths |
string[] |
The absolute path of all templates to be processed. |
appConstruct |
constructs.IConstruct |
No description. |
public readonly templatePaths: string[];- Type: string[]
The absolute path of all templates to be processed.
public readonly appConstruct: IConstruct;- Type: constructs.IConstruct
The severity level of the rule.
| Name | Description |
|---|---|
WARN |
No description. |
ERROR |
No description. |
INFO |
No description. |
Possible output formats of the NagReport.
| Name | Description |
|---|---|
CSV |
No description. |
JSON |
No description. |
The compliance level of a resource in relation to a rule.
| Name | Description |
|---|---|
COMPLIANT |
No description. |
NON_COMPLIANT |
No description. |
NOT_APPLICABLE |
No description. |
Additional states a rule can be in post compliance validation.
| Name | Description |
|---|---|
UNKNOWN |
No description. |