Skip to content
v2.275.0

CloudFormationValidatePlugin Class ​

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

Example ​

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
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
// 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());
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
    } }
}));
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 ​

ts
new CloudFormationValidatePlugin(props?: CloudFormationValidatePluginProps)
python
CloudFormationValidatePlugin(props: typing.Optional[CloudFormationValidatePluginProps] = None)
java
new CloudFormationValidatePlugin(CloudFormationValidatePluginProps props)
csharp
new CloudFormationValidatePlugin(CloudFormationValidatePluginProps? props = null)
go
NewCloudFormationValidatePlugin(Props CloudFormationValidatePluginProps)

Properties ​

namestringnamestrnameStringNamestringName*string#
The name of the plugin that will be displayed in the validation report.
PLUGIN_NAMEstringplugin_namestrPLUGIN_NAMEStringPLUGIN_NAMEstringPLUGIN_NAME*stringstatic#
The default name of this plugin.
ruleIdsmay be undefinedstring[]rule_idsmay be undefinedtyping.List[str]ruleIdsmay be undefinedList<String>RuleIdsmay be undefinedstring[]RuleIdsmay be undefined*[]*string#
The list of rule IDs that the plugin will evaluate.

Used for analytics purposes.

versionmay be undefinedstringversionmay be undefinedstrversionmay be undefinedStringVersionmay be undefinedstringVersionmay be undefined*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): PolicyValidationPluginReportdef validate(self, context: IPolicyValidationContext) -> PolicyValidationPluginReportpublic PolicyValidationPluginReport validate(IPolicyValidationContext context)public PolicyValidationPluginReport Validate(IPolicyValidationContext context)func 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