Skip to content
v2.274.0

ResourceWithPolicies Class ​

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.

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();
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_iam as iam

resource_with_policies = iam.ResourceWithPolicies()
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.iam.*;

ResourceWithPolicies resourceWithPolicies = new ResourceWithPolicies();
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.AWS.IAM;

var resourceWithPolicies = new ResourceWithPolicies();
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 "github.com/aws/aws-cdk-go/awscdk"

resourceWithPolicies := awscdk.Aws_iam.NewResourceWithPolicies()

Initializer ​

ts
new ResourceWithPolicies()
python
ResourceWithPolicies()
java
new ResourceWithPolicies()
csharp
new ResourceWithPolicies()
go
NewResourceWithPolicies()

Methods ​

of(resource: IEnvironmentAware): IResourceWithPolicyV2@staticmethod def of(resource: IEnvironmentAware) -> IResourceWithPolicyV2public static IResourceWithPolicyV2 of(IEnvironmentAware resource)public static IResourceWithPolicyV2 Of(IEnvironmentAware resource)func Of(Resource IEnvironmentAware) IResourceWithPolicyV2static#
Retrieve the IResourceWithPolicyV2 associated with a construct, if available.
register(scope: IConstruct, cfnType: string, factory: IResourcePolicyFactory): void@staticmethod def register(scope: IConstruct, cfn_type: str, factory: IResourcePolicyFactory) -> Nonepublic static void register(IConstruct scope, String cfnType, IResourcePolicyFactory factory)public static void Register(IConstruct scope, string cfnType, IResourcePolicyFactory factory)func Register(Scope IConstruct, CfnType *string, Factory IResourcePolicyFactory)static#
Register a factory for a specific CloudFormation resource type and scope.