Class PolicyStatement
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
A statement names the principal, action and resource it applies to, and optionally conditions that narrow it further. All three parts are required, so a statement is complete as soon as it is constructed.
Example:
import software.amazon.awscdk.services.bedrockagentcore.Policy;
import software.amazon.awscdk.services.bedrockagentcore.PolicyEngine;
import software.amazon.awscdk.services.bedrockagentcore.PolicyStatement;
PolicyEngine engine;
// Example 4: raw Cedar, for features the API does not model
// Example 4: raw Cedar, for features the API does not model
Policy.Builder.create(this, "CustomPolicy")
.policyEngine(engine)
.statement(PolicyStatement.fromCedar("permit(principal, action, resource) when { context.custom > 10 };"))
.build();
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPolicyStatement(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedPolicyStatement(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic PolicyStatementCreate a statement from raw Cedar source.toCedar()Generate the Cedar policy statement string.Methods 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, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
PolicyStatement
protected PolicyStatement(software.amazon.jsii.JsiiObjectRef objRef) -
PolicyStatement
protected PolicyStatement(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
PolicyStatement
- Parameters:
props- This parameter is required.
-
-
Method Details
-
fromCedar
Create a statement from raw Cedar source.Use this for Cedar features this API does not model, or to migrate an existing policy.
The source is used exactly as given. This method does not escape, quote, or validate it, so it is treated as trusted input and you own its correctness and its safety. Do not build the string by joining values that come from outside your application: a value containing a double quote can close a string literal early and add policy statements you did not write. Pass such values through
PolicyConditionand the principal, action and resource factories instead, which reject that case at synthesis time. Service-side validation does not help, because an injected policy is still valid Cedar.- Parameters:
cedarStatement-- Complete Cedar policy statement.
-
toCedar
Generate the Cedar policy statement string.This is called internally by the Policy construct.
- Returns:
- Valid Cedar policy statement
-