# IPolicyValidationPlugin

Represents a validation plugin that will be executed during synthesis.

Implemented by: [CloudFormationValidatePlugin](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CloudFormationValidatePlugin.html)

- Source: [`core/lib/validation/validation.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/core/lib/validation/validation.ts#L33)
- Type last changed: v2.251.0 · 24 Apr 2026

## Example

TypeScript:

```ts
/// fixture=validation-plugin
class MyPlugin implements IPolicyValidationPlugin {
  public readonly name = 'MyPlugin';

  public validate(context: IPolicyValidationContext): PolicyValidationPluginReport {
    // First read the templates using context.templatePaths...

    // ...then perform the validation, and then compose and return the report.
    // Using hard-coded values here for better clarity:
    return {
      success: false,
      violations: [{
        ruleName: 'CKV_AWS_117',
        description: 'Ensure that AWS Lambda function is configured inside a VPC',
        fix: 'https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1',
        violatingResources: [{
          resourceLogicalId: 'MyFunction3BAA72D1',
          templatePath: '/home/johndoe/myapp/cdk.out/MyService.template.json',
          locations: ['Properties/VpcConfig'],
        }],
      }],
    };
  }
}
```

Python:

```python
from aws_cdk import PolicyValidationPluginReport, PolicyViolation, PolicyViolatingResource
@jsii.implements(IPolicyValidationPlugin)
class MyPlugin:

    def validate(self, context):
        # First read the templates using context.templatePaths...

        # ...then perform the validation, and then compose and return the report.
        # Using hard-coded values here for better clarity:
        return PolicyValidationPluginReport(
            success=False,
            violations=[PolicyViolation(
                rule_name="CKV_AWS_117",
                description="Ensure that AWS Lambda function is configured inside a VPC",
                fix="https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1",
                violating_resources=[PolicyViolatingResource(
                    resource_logical_id="MyFunction3BAA72D1",
                    template_path="/home/johndoe/myapp/cdk.out/MyService.template.json",
                    locations=["Properties/VpcConfig"]
                )]
            )]
        )
```

Java:

```java
public class MyPlugin implements IPolicyValidationPlugin {
    public final Object name;

    public PolicyValidationPluginReport validate(IPolicyValidationContext context) {
        // First read the templates using context.templatePaths...

        // ...then perform the validation, and then compose and return the report.
        // Using hard-coded values here for better clarity:
        return PolicyValidationPluginReport.builder()
                .success(false)
                .violations(List.of(PolicyViolation.builder()
                        .ruleName("CKV_AWS_117")
                        .description("Ensure that AWS Lambda function is configured inside a VPC")
                        .fix("https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1")
                        .violatingResources(List.of(PolicyViolatingResource.builder()
                                .resourceLogicalId("MyFunction3BAA72D1")
                                .templatePath("/home/johndoe/myapp/cdk.out/MyService.template.json")
                                .locations(List.of("Properties/VpcConfig"))
                                .build()))
                        .build()))
                .build();
    }
}
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
class MyPlugin : IPolicyValidationPlugin
{
    public readonly void Name = "MyPlugin";

    public PolicyValidationPluginReport Validate(IPolicyValidationContext context)
    {
        // First read the templates using context.templatePaths...

        // ...then perform the validation, and then compose and return the report.
        // Using hard-coded values here for better clarity:
        return new PolicyValidationPluginReport {
            Success = false,
            Violations = new [] { new PolicyViolation {
                RuleName = "CKV_AWS_117",
                Description = "Ensure that AWS Lambda function is configured inside a VPC",
                Fix = "https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1",
                ViolatingResources = new [] { new PolicyViolatingResource {
                    ResourceLogicalId = "MyFunction3BAA72D1",
                    TemplatePath = "/home/johndoe/myapp/cdk.out/MyService.template.json",
                    Locations = new [] { "Properties/VpcConfig" }
                } }
            } }
        };
    }
}
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
type myPlugin struct {
	name
}

func (this *myPlugin) validate(context IPolicyValidationContext) PolicyValidationPluginReport {
	// First read the templates using context.templatePaths...

	// ...then perform the validation, and then compose and return the report.
	// Using hard-coded values here for better clarity:
	return &PolicyValidationPluginReport{
		Success: jsii.Boolean(false),
		Violations: []PolicyViolation{
			&PolicyViolation{
				RuleName: jsii.String("CKV_AWS_117"),
				Description: jsii.String("Ensure that AWS Lambda function is configured inside a VPC"),
				Fix: jsii.String("https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1"),
				ViolatingResources: []PolicyViolatingResource{
					&PolicyViolatingResource{
						ResourceLogicalId: jsii.String("MyFunction3BAA72D1"),
						TemplatePath: jsii.String("/home/johndoe/myapp/cdk.out/MyService.template.json"),
						Locations: []*string{
							jsii.String("Properties/VpcConfig"),
						},
					},
				},
			},
		},
	}
}
```

## Properties

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

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

  **Default:** No rule is reported

  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
