Skip to content
v2.278.0

PolicyViolationJson Struct ​

A single policy violation found by a validation plugin.

Example ​

ts
import { PolicyViolationJson } from '@aws-cdk/cloud-assembly-schema';

const violation: PolicyViolationJson = {
  ruleName: 'no-public-access',
  description: 'S3 bucket should not allow public access',
  severity: 'error',
  violatingConstructs: [{ constructPath: 'MyStack/MyBucket' }],
};
python
from aws_cdk.cloud_assembly_schema import PolicyViolationJson, ViolatingConstructJson
from aws_cdk.cloud_assembly_schema import PolicyViolationJson


violation = PolicyViolationJson(
    rule_name="no-public-access",
    description="S3 bucket should not allow public access",
    severity="error",
    violating_constructs=[ViolatingConstructJson(construct_path="MyStack/MyBucket")]
)
java
import software.amazon.awscdk.cloudassembly.schema.PolicyViolationJson;


PolicyViolationJson violation = PolicyViolationJson.builder()
        .ruleName("no-public-access")
        .description("S3 bucket should not allow public access")
        .severity("error")
        .violatingConstructs(List.of(ViolatingConstructJson.builder().constructPath("MyStack/MyBucket").build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.CloudAssembly.Schema;


var violation = new PolicyViolationJson {
    RuleName = "no-public-access",
    Description = "S3 bucket should not allow public access",
    Severity = "error",
    ViolatingConstructs = new [] { new ViolatingConstructJson { ConstructPath = "MyStack/MyBucket" } }
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/cdklabs/cloud-assembly-schema-go/awscdkcloudassemblyschema"


violation := &PolicyViolationJson{
	RuleName: jsii.String("no-public-access"),
	Description: jsii.String("S3 bucket should not allow public access"),
	Severity: jsii.String("error"),
	ViolatingConstructs: []ViolatingConstructJson{
		&ViolatingConstructJson{
			ConstructPath: jsii.String("MyStack/MyBucket"),
		},
	},
}

Properties ​

customSeverityoptionalstringcustom_severityoptionalstrcustomSeverityoptionalStringCustomSeverityoptionalstringCustomSeverityoptional*string #
If the plugin wants to report using a non-standard severity, put it here.
descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string required #
A description of the violation.
ruleMetadataoptional{ [key: string]: string }rule_metadataoptionaltyping.Mapping[str, str]ruleMetadataoptionalMap<String, String>RuleMetadataoptionalIDictionary<string, string>RuleMetadataoptional*map[string]*string #
Additional rule-specific metadata.

Default: no metadata

ruleNamestringrule_namestrruleNameStringRuleNamestringRuleName*string required #
The name of the rule that was violated.

This may include a namespace: '<namespace>::<rule-name>'. If it does not, the plugin name will be used as the namespace.

The namespace must be included when acknowledging the violation.

severitystringseveritystrseverityStringSeveritystringSeverity*string required #
The severity of the violation.
suggestedFixoptionalstringsuggested_fixoptionalstrsuggestedFixoptionalStringSuggestedFixoptionalstringSuggestedFixoptional*string #
How to fix the violation.

Default: no fix provided

violatingConstructsViolatingConstructJson[]violating_constructstyping.List[ViolatingConstructJson]violatingConstructsList<ViolatingConstructJson>ViolatingConstructsViolatingConstructJson[]ViolatingConstructs*[]ViolatingConstructJson required #
Constructs that violated the rule.