# PolicyViolatingResource

Resource violating a specific rule.

- Source: [`core/lib/validation/report.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/core/lib/validation/report.ts#L49)
- Type last changed: v2.253.0 · 6 May 2026

## Example

TypeScript:

```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 policyViolatingResource: cdk.PolicyViolatingResource = {
  locations: ['locations'],

  // the properties below are optional
  constructPath: 'constructPath',
  resourceLogicalId: 'resourceLogicalId',
  templatePath: 'templatePath',
};
```

Python:

```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_violating_resource = cdk.PolicyViolatingResource(
    locations=["locations"],

    # the properties below are optional
    construct_path="constructPath",
    resource_logical_id="resourceLogicalId",
    template_path="templatePath"
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

PolicyViolatingResource policyViolatingResource = PolicyViolatingResource.builder()
        .locations(List.of("locations"))

        // the properties below are optional
        .constructPath("constructPath")
        .resourceLogicalId("resourceLogicalId")
        .templatePath("templatePath")
        .build();
```

C# / .NET:

```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 policyViolatingResource = new PolicyViolatingResource {
    Locations = new [] { "locations" },

    // the properties below are optional
    ConstructPath = "constructPath",
    ResourceLogicalId = "resourceLogicalId",
    TemplatePath = "templatePath"
};
```

Golang:

```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"

policyViolatingResource := &PolicyViolatingResource{
	Locations: []*string{
		jsii.String("locations"),
	},

	// the properties below are optional
	ConstructPath: jsii.String("constructPath"),
	ResourceLogicalId: jsii.String("resourceLogicalId"),
	TemplatePath: jsii.String("templatePath"),
}
```

## Properties

- `constructPath`: string — The construct path of the violating construct.

  **Default:** construct path is derived from the resource logical ID

  Use this for violations that originate from constructs rather than
  CloudFormation resources (e.g. annotations added via `Annotations.of()`
  or `Validations.of()`). When provided, the report will use this path
  directly instead of deriving it from the resource logical ID.
  Mutually exclusive with `resourceLogicalId`.

- `locations`: string[] (required) — The locations in the CloudFormation template that pose the violations.

  This is a location in the CloudFormation template, relative to the resource that
  this violation is about. For example, if the violation is about a property of a resource,
  this will contain something like `Properties.MyProperty`. If the violation is about the Stack
  itself, it will contain something like `Parameters.MyParameter`.

- `resourceLogicalId`: string — The logical ID of the resource in the CloudFormation template.

  **Default:** no resource logical ID

  Intended for plugin-sourced violations that operate on CloudFormation
  templates.

  If set, the `constructPath` will be added later.

- `templatePath`: string — The path to the CloudFormation template that contains this resource.

  **Default:** no template path
