# CloudFormationValidatePlugin

Validation plugin that uses the CloudFormation validation engine to evaluate templates against built-in rules.

Implements: [IPolicyValidationPlugin](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IPolicyValidationPlugin.html)

- Source: [`core/lib/validation/cloudformation-validate-plugin.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/core/lib/validation/cloudformation-validate-plugin.ts#L94)
- Type last changed: v2.262.0 · 22 Jul 2026

## Example

TypeScript:

```ts
const app = new App();

// Rules text, read from disk perhaps
declare const myRules: string;

Validations.of(app).addPlugins(new CloudFormationValidatePlugin({
  guardRules: [{
    name: 'My rules',
    content: myRules,
  }],
}));
```

Python:

```python
from aws_cdk import ValidationRuleSource

# Rules text, read from disk perhaps
# my_rules: str
app = App()

Validations.of(app).add_plugins(CloudFormationValidatePlugin(
    guard_rules=[ValidationRuleSource(
        name="My rules",
        content=my_rules
    )]
))
```

Java:

```java
// Rules text, read from disk perhaps
String myRules;
App app = new App();

Validations.of(app).addPlugins(CloudFormationValidatePlugin.Builder.create()
        .guardRules(List.of(ValidationRuleSource.builder()
                .name("My rules")
                .content(myRules)
                .build()))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Rules text, read from disk perhaps
string myRules;
var app = new App();

Validations.Of(app).AddPlugins(new CloudFormationValidatePlugin(new CloudFormationValidatePluginProps {
    GuardRules = new [] { new ValidationRuleSource {
        Name = "My rules",
        Content = myRules
    } }
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Rules text, read from disk perhaps
var myRules string
app := awscdk.NewApp()

awscdk.Validations_Of(app).AddPlugins(awscdk.NewCloudFormationValidatePlugin(&CloudFormationValidatePluginProps{
	GuardRules: []ValidationRuleSource{
		&ValidationRuleSource{
			Name: jsii.String("My rules"),
			Content: myRules,
		},
	},
}))
```

## Initializer

TypeScript:

```ts
new CloudFormationValidatePlugin(props?: CloudFormationValidatePluginProps)
```

Python:

```python
CloudFormationValidatePlugin(props: typing.Optional[CloudFormationValidatePluginProps] = None)
```

Java:

```java
new CloudFormationValidatePlugin(CloudFormationValidatePluginProps props)
```

C# / .NET:

```csharp
new CloudFormationValidatePlugin(CloudFormationValidatePluginProps? props = null)
```

Golang:

```go
NewCloudFormationValidatePlugin(Props CloudFormationValidatePluginProps)
```

## Properties

- `name`: string — The name of the plugin that will be displayed in the validation report.

- `PLUGIN_NAME`: string (static) — The default name of this plugin.

- `ruleIds`: string[] — The list of rule IDs that the plugin will evaluate.

  Used for analytics
  purposes.

- `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`.

## Methods

- `validate(context: IPolicyValidationContext): PolicyValidationPluginReport` — The method that will be called by the CDK framework to perform validations.

  This is where the plugin will evaluate the CloudFormation
  templates for compliance and report and violations
