PolicyViolation Struct
Violation produced by the validation plugin.
| Source | core/lib/validation/report.ts |
|---|---|
| Type last changed |
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const policyViolation: cdk.PolicyViolation = {
description: 'description',
ruleName: 'ruleName',
violatingResources: [{
locations: ['locations'],
// the properties below are optional
constructPath: 'constructPath',
resourceLogicalId: 'resourceLogicalId',
templatePath: 'templatePath',
}],
// the properties below are optional
fix: 'fix',
ruleMetadata: {
ruleMetadataKey: 'ruleMetadata',
},
severity: 'severity',
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
policy_violation = cdk.PolicyViolation(
description="description",
rule_name="ruleName",
violating_resources=[cdk.PolicyViolatingResource(
locations=["locations"],
# the properties below are optional
construct_path="constructPath",
resource_logical_id="resourceLogicalId",
template_path="templatePath"
)],
# the properties below are optional
fix="fix",
rule_metadata={
"rule_metadata_key": "ruleMetadata"
},
severity="severity"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
PolicyViolation policyViolation = PolicyViolation.builder()
.description("description")
.ruleName("ruleName")
.violatingResources(List.of(PolicyViolatingResource.builder()
.locations(List.of("locations"))
// the properties below are optional
.constructPath("constructPath")
.resourceLogicalId("resourceLogicalId")
.templatePath("templatePath")
.build()))
// the properties below are optional
.fix("fix")
.ruleMetadata(Map.of(
"ruleMetadataKey", "ruleMetadata"))
.severity("severity")
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
var policyViolation = new PolicyViolation {
Description = "description",
RuleName = "ruleName",
ViolatingResources = new [] { new PolicyViolatingResource {
Locations = new [] { "locations" },
// the properties below are optional
ConstructPath = "constructPath",
ResourceLogicalId = "resourceLogicalId",
TemplatePath = "templatePath"
} },
// the properties below are optional
Fix = "fix",
RuleMetadata = new Dictionary<string, string> {
{ "ruleMetadataKey", "ruleMetadata" }
},
Severity = "severity"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
policyViolation := &PolicyViolation{
Description: jsii.String("description"),
RuleName: jsii.String("ruleName"),
ViolatingResources: []PolicyViolatingResource{
&PolicyViolatingResource{
Locations: []*string{
jsii.String("locations"),
},
// the properties below are optional
ConstructPath: jsii.String("constructPath"),
ResourceLogicalId: jsii.String("resourceLogicalId"),
TemplatePath: jsii.String("templatePath"),
},
},
// the properties below are optional
Fix: jsii.String("fix"),
RuleMetadata: map[string]*string{
"ruleMetadataKey": jsii.String("ruleMetadata"),
},
Severity: jsii.String("severity"),
}
Properties
The description of the violation.
How to fix the violation.
Default: no fix is provided
ruleMetadataoptional{ [key: string]: string }rule_metadataoptionaltyping.Mapping[str, str]ruleMetadataoptionalMap<String, String>RuleMetadataoptionalIDictionary<string, string>RuleMetadataoptional*map[string]*string #Additional metadata to include with the rule results.
Default: no rule metadata
This can be used to provide additional information that is plugin specific. The data provided here will be rendered as is.
The name of the rule.
severityoptionalstringseverityoptionalstrseverityoptionalStringSeverityoptionalstringSeverityoptional*string #The severity of the violation, only used for reporting purposes.
Default: no severity
This is useful for helping the user discriminate between warnings, errors, information, etc.
violatingResourcesPolicyViolatingResource[]violating_resourcestyping.List[PolicyViolatingResource]violatingResourcesList<PolicyViolatingResource>ViolatingResourcesPolicyViolatingResource[]ViolatingResources*[]PolicyViolatingResource required #The resources violating this rule.