# ResourceWithPolicies

Utility class for discovering and managing resource policy traits.

This class provides methods to retrieve IResourceWithPolicyV2 instances from constructs,
enabling resource-based policy management during IAM grant operations.

- Source: [`aws-iam/lib/grant.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-iam/lib/grant.ts#L447)
- Type last changed: v2.239.0 · 19 Feb 2026

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_iam as iam } from 'aws-cdk-lib';
const resourceWithPolicies = new iam.ResourceWithPolicies();
```

## Initializer

```ts
new ResourceWithPolicies()
```

## Methods

- `of(resource: IEnvironmentAware): IResourceWithPolicyV2` (static) — Retrieve the IResourceWithPolicyV2 associated with a construct, if available.

- `register(scope: IConstruct, cfnType: string, factory: IResourcePolicyFactory): void` (static) — Register a factory for a specific CloudFormation resource type and scope.
