@@ -1614,31 +1614,20 @@ generated CloudFormation templates against your policies immediately after
16141614synthesis. If there are any violations, the synthesis will fail and a report
16151615will be printed to the console or to a file (see below).
16161616
1617- > [!NOTE]
1618- > This feature is considered experimental, and both the plugin API and the
1619- > format of the validation report are subject to change in the future.
1620-
16211617# ## For application developers
16221618
16231619To use one or more validation plugins in your application, use the
1624- `policyValidationBeta1` property of `Stage` :
1620+ `Validations.of()` API :
16251621
16261622` ` ` ts fixture=validation-plugin
16271623// globally for the entire app (an app is a stage)
1628- const app = new App({
1629- policyValidationBeta1: [
1630- // These hypothetical classes implement IPolicyValidationPluginBeta1:
1631- new ThirdPartyPluginX(),
1632- new ThirdPartyPluginY(),
1633- ],
1634- });
1624+ const app = new App();
1625+ Validations.of(app).addPlugins(new ThirdPartyPluginX());
1626+ Validations.of(app).addPlugins(new ThirdPartyPluginY());
16351627
16361628// only apply to a particular stage
1637- const prodStage = new Stage(app, 'ProdStage', {
1638- policyValidationBeta1: [
1639- new ThirdPartyPluginX(),
1640- ],
1641- });
1629+ const prodStage = new Stage(app, 'ProdStage');
1630+ Validations.of(prodStage).addPlugins(new ThirdPartyPluginX());
16421631` ` `
16431632
16441633Immediately after synthesis, all plugins registered this way will be invoked to
@@ -1656,7 +1645,7 @@ By default, the report will be printed in a human-readable format. If you want a
16561645report in JSON format, enable it using the `@aws-cdk/core:validationReportJson`
16571646context passing it directly to the application :
16581647
1659- ` ` ` ts
1648+ ` ` ` ts fixture=validation-plugin
16601649const app = new App({
16611650 context: { '@aws-cdk/core:validationReportJson': true },
16621651});
@@ -1669,7 +1658,7 @@ Alternatively, you can set this context key-value pair using the `cdk.json` or
16691658It is also possible to enable both JSON and human-readable formats by setting
16701659`@aws-cdk/core:validationReportPrettyPrint` context key explicitly :
16711660
1672- ` ` ` ts
1661+ ` ` ` ts fixture=validation-plugin
16731662const app = new App({
16741663 context: {
16751664 '@aws-cdk/core:validationReportJson': true,
@@ -1686,21 +1675,21 @@ the standard output.
16861675# ## For plugin authors
16871676
16881677The communication protocol between the CDK core module and your policy tool is
1689- defined by the `IPolicyValidationPluginBeta1 ` interface. To create a new plugin you must
1678+ defined by the `IPolicyValidationPlugin ` interface. To create a new plugin you must
16901679write a class that implements this interface. There are two things you need to
16911680implement : the plugin name (by overriding the `name` property), and the
16921681` validate()` method.
16931682
1694- The framework will call `validate()`, passing an `IPolicyValidationContextBeta1 ` object.
1683+ The framework will call `validate()`, passing an `IPolicyValidationContext ` object.
16951684The location of the templates to be validated is given by `templatePaths`. The
1696- plugin should return an instance of `PolicyValidationPluginReportBeta1 `. This object
1697- represents the report that the user wil receive at the end of the synthesis.
1685+ plugin should return an instance of `PolicyValidationPluginReport `. This object
1686+ represents the report that the user will receive at the end of the synthesis.
16981687
16991688` ` ` ts fixture=validation-plugin
1700- class MyPlugin implements IPolicyValidationPluginBeta1 {
1689+ class MyPlugin implements IPolicyValidationPlugin {
17011690 public readonly name = 'MyPlugin';
17021691
1703- public validate(context: IPolicyValidationContextBeta1 ): PolicyValidationPluginReportBeta1 {
1692+ public validate(context: IPolicyValidationContext ): PolicyValidationPluginReport {
17041693 // First read the templates using context.templatePaths...
17051694
17061695 // ...then perform the validation, and then compose and return the report.
@@ -1723,7 +1712,7 @@ class MyPlugin implements IPolicyValidationPluginBeta1 {
17231712` ` `
17241713
17251714In addition to the name, plugins may optionally report their version (`version`
1726- property ) and a list of IDs of the rules they are going to evaluate (`ruleIds`
1715+ property) and a list of IDs of the rules they are going to evaluate (`ruleIds`
17271716property).
17281717
17291718Note that plugins are not allowed to modify anything in the cloud assembly. Any
0 commit comments