Skip to content
v2.277.0

PolicyResource Class ​

The resource a policy statement applies to.

AgentCore rejects a policy whose resource is an unconstrained wildcard, so a statement must name either a resource type or a specific resource.

Example ​

ts
import { PolicyResource } from 'aws-cdk-lib/aws-bedrockagentcore';
declare const gatewayArn: string;

PolicyResource.anyOfType('AgentCore::Gateway'); // resource is AgentCore::Gateway
PolicyResource.instance('AgentCore::Gateway', gatewayArn); // resource == AgentCore::Gateway::"<arn>"
python
from aws_cdk.aws_bedrockagentcore import PolicyResource
# gateway_arn: str


PolicyResource.any_of_type("AgentCore::Gateway") # resource is AgentCore::Gateway
PolicyResource.instance("AgentCore::Gateway", gateway_arn)
java
import software.amazon.awscdk.services.bedrockagentcore.PolicyResource;
String gatewayArn;


PolicyResource.anyOfType("AgentCore::Gateway"); // resource is AgentCore::Gateway
PolicyResource.instance("AgentCore::Gateway", gatewayArn);
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.BedrockAgentCore;
string gatewayArn;


PolicyResource.AnyOfType("AgentCore::Gateway"); // resource is AgentCore::Gateway
PolicyResource.Instance("AgentCore::Gateway", gatewayArn);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
var gatewayArn string


awscdk.PolicyResource_AnyOfType(jsii.String("AgentCore::Gateway")) // resource is AgentCore::Gateway
awscdk.PolicyResource_Instance(jsii.String("AgentCore::Gateway"), gatewayArn)

Methods ​

anyOfType(entityType: string): PolicyResource // chainable@staticmethod def any_of_type(entity_type: str) -> PolicyResourcepublic static PolicyResource anyOfType(String entityType)public static PolicyResource AnyOfType(string entityType)func AnyOfType(EntityType *string) PolicyResourcestatic#
Any resource of the given entity type.
1 parameter

Parameters

  • entityTypeentity_typeentityTypeentityTypeEntityType — - The entity type, for example 'AgentCore::Gateway'.
instance(entityType: string, entityArn: string): PolicyResource // chainable@staticmethod def instance(entity_type: str, entity_arn: str) -> PolicyResourcepublic static PolicyResource instance(String entityType, String entityArn)public static PolicyResource Instance(string entityType, string entityArn)func Instance(EntityType *string, EntityArn *string) PolicyResourcestatic#
One specific resource.

AgentCore requires a specific resource when the statement names specific actions rather than any action.

2 parameters

Parameters

  • entityTypeentity_typeentityTypeentityTypeEntityType — - The entity type, for example 'AgentCore::Gateway'.
  • entityArnentity_arnentityArnentityArnEntityArn — - The resource ARN or identifier.