Class PolicyEngine
- All Implemented Interfaces:
IPolicyEngineRef,IEnvironmentAware,IResource,IPolicyEngine,IGrantable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
PolicyEngine enables deterministic authorization control for Bedrock agents, allowing fine-grained access control to tools and actions via Cedar policy language.
Example:
IPolicyEngine importedEngine = PolicyEngine.fromPolicyEngineAttributes(this, "ImportedEngine", PolicyEngineAttributes.builder()
.policyEngineArn("policy-engine/my-engine-id")
.build());
IPolicy importedPolicy = Policy.fromPolicyAttributes(this, "ImportedPolicy", PolicyAttributes.builder()
.policyArn("my-policy-arn")
.policyEngine(importedEngine)
.build());
// Grant permissions to the imported policy
Role role = Role.Builder.create(this, "PolicyRole")
.assumedBy(new ServicePrincipal("lambda.amazonaws.com"))
.build();
importedPolicy.grantRead(role);
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.bedrockagentcore.IPolicyEngine
IPolicyEngine.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPolicyEngine(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedPolicyEngine(software.amazon.jsii.JsiiObjectRef objRef) PolicyEngine(software.constructs.Construct scope, String id) PolicyEngine(software.constructs.Construct scope, String id, PolicyEngineProps props) -
Method Summary
Modifier and TypeMethodDescriptionaddPolicy(String id, AddPolicyOptions options) Add a policy to this policy engine.static IPolicyEnginefromPolicyEngineAttributes(software.constructs.Construct scope, String id, PolicyEngineAttributes attrs) Creates a PolicyEngine reference from an existing policy engine's attributes.The description of the policy engine.The principal to grant permissions to.The KMS key used to encrypt the policy engine.Get the list of policies added to this policy engine.The ARN of the policy engine resource.The ID of the policy engine.The name of the policy engine.getTags()Tags applied to this policy engine resource.Methods inherited from class software.amazon.awscdk.services.bedrockagentcore.PolicyEngineBase
getPolicyEngineRef, grant, grantEvaluate, grantEvaluateForGateway, grantRead, metric, metric, metricAuthorizationLatency, metricAuthorizationLatency, metricAuthorizations, metricAuthorizations, metricDeniedRequests, metricDeniedRequests, metricErrors, metricErrorsMethods inherited from class software.amazon.awscdk.Resource
applyCrossStackReferenceStrength, applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource, withMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNode, withMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
Uniquely identifies this class.
-
-
Constructor Details
-
PolicyEngine
protected PolicyEngine(software.amazon.jsii.JsiiObjectRef objRef) -
PolicyEngine
protected PolicyEngine(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
PolicyEngine
@Stability(Stable) public PolicyEngine(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable PolicyEngineProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props-
-
PolicyEngine
@Stability(Stable) public PolicyEngine(@NotNull software.constructs.Construct scope, @NotNull String id) - Parameters:
scope- This parameter is required.id- This parameter is required.
-
-
Method Details
-
fromPolicyEngineAttributes
@Stability(Stable) @NotNull public static IPolicyEngine fromPolicyEngineAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull PolicyEngineAttributes attrs) Creates a PolicyEngine reference from an existing policy engine's attributes.- Parameters:
scope-- The construct scope.
id-- Identifier of the construct.
attrs-- Attributes of the existing policy engine.
- Returns:
- An IPolicyEngine reference to the existing policy engine
-
addPolicy
@Stability(Stable) @NotNull public Policy addPolicy(@NotNull String id, @NotNull AddPolicyOptions options) Add a policy to this policy engine. Convenience method that creates a Policy construct with this engine as the parent.Automatic Sequential Chaining: By default, policies are automatically chained sequentially to prevent concurrent creation issues with the AWS Bedrock AgentCore service. Each new policy will depend on the previous policy added to this engine.
This ensures policies are created one at a time, avoiding "Resource stabilization failed" errors that occur with concurrent policy operations.
- Parameters:
id-- Unique identifier for the policy construct.
options-- Options for creating the policy.
- Returns:
- The created Policy construct
-
getGrantPrincipal
The principal to grant permissions to.- Specified by:
getGrantPrincipalin interfaceIGrantable- Specified by:
getGrantPrincipalin classPolicyEngineBase
-
getPolicies
Get the list of policies added to this policy engine.Returns an array of Policy constructs that were added using addPolicy(). This allows you to iterate over all policies associated with this engine.
- Returns:
- A copy of the policies array
-
getPolicyEngineArn
The ARN of the policy engine resource.- Specified by:
getPolicyEngineArnin interfaceIPolicyEngine- Specified by:
getPolicyEngineArnin classPolicyEngineBase
-
getPolicyEngineId
The ID of the policy engine.- Specified by:
getPolicyEngineIdin interfaceIPolicyEngine- Specified by:
getPolicyEngineIdin classPolicyEngineBase
-
getPolicyEngineName
The name of the policy engine.[disable-awslint:attribute-tag]
- Specified by:
getPolicyEngineNamein interfaceIPolicyEngine- Specified by:
getPolicyEngineNamein classPolicyEngineBase
-
getDescription
The description of the policy engine.- Specified by:
getDescriptionin interfaceIPolicyEngine- Specified by:
getDescriptionin classPolicyEngineBase
-
getKmsKey
The KMS key used to encrypt the policy engine.- Specified by:
getKmsKeyin interfaceIPolicyEngine- Specified by:
getKmsKeyin classPolicyEngineBase
-
getTags
Tags applied to this policy engine resource.Default: - No tags applied
-