java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IPolicyRef, IEnvironmentAware, IResource, IPolicy, IGrantable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.139.0 (build 26a6b54)", date="2026-09-10T17:51:40.337Z") @Stability(Stable) public class Policy extends PolicyBase
Individual Cedar policy defining what agents can access.

Policies use Cedar language to specify precise access control rules that are evaluated deterministically by the PolicyEngine.

Example:

 PolicyEngine policyEngine;
 Policy advancedPolicy = Policy.Builder.create(this, "AdvancedPolicy")
         .policyEngine(policyEngine)
         .statement(PolicyStatement.fromCedar("permit(principal, action, resource) when { context.custom > 10 };"))
         .description("Advanced policy with custom Cedar logic")
         .build();
 policyEngine.addPolicy("CustomPolicy", AddPolicyOptions.builder()
         .statement(PolicyStatement.fromCedar("forbid(principal, action, resource) when { resource.confidential == true };"))
         .description("Custom policy from Cedar string")
         .build());
 

See Also:
  • Field Details

    • PROPERTY_INJECTION_ID

      @Stability(Stable) public static final String PROPERTY_INJECTION_ID
      Uniquely identifies this class.
  • Constructor Details

    • Policy

      protected Policy(software.amazon.jsii.JsiiObjectRef objRef)
    • Policy

      protected Policy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Policy

      @Stability(Stable) public Policy(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull PolicyProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromPolicyAttributes

      @Stability(Stable) @NotNull public static IPolicy fromPolicyAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull PolicyAttributes attrs)
      Creates a Policy reference from an existing policy's attributes.

      Parameters:
      scope -
      • The construct scope.
      This parameter is required.
      id -
      • Identifier of the construct.
      This parameter is required.
      attrs -
      • Attributes of the existing policy.
      This parameter is required.
      Returns:
      An IPolicy reference to the existing policy
    • getDefinition

      @Stability(Stable) @NotNull public String getDefinition()
      The Cedar policy definition.
    • getGrantPrincipal

      @Stability(Stable) @NotNull public IPrincipal getGrantPrincipal()
      The principal to grant permissions to.
      Specified by:
      getGrantPrincipal in interface IGrantable
      Specified by:
      getGrantPrincipal in class PolicyBase
    • getPolicyArn

      @Stability(Stable) @NotNull public String getPolicyArn()
      The ARN of the policy resource.
      Specified by:
      getPolicyArn in interface IPolicy
      Specified by:
      getPolicyArn in class PolicyBase
    • getPolicyEngine

      @Stability(Stable) @NotNull public IPolicyEngine getPolicyEngine()
      The policy engine this policy belongs to.

      [disable-awslint:attribute-tag]

      Specified by:
      getPolicyEngine in interface IPolicy
      Specified by:
      getPolicyEngine in class PolicyBase
    • getPolicyId

      @Stability(Stable) @NotNull public String getPolicyId()
      The ID of the policy.
      Specified by:
      getPolicyId in interface IPolicy
      Specified by:
      getPolicyId in class PolicyBase
    • getPolicyName

      @Stability(Stable) @NotNull public String getPolicyName()
      The name of the policy.

      [disable-awslint:attribute-tag]

      Specified by:
      getPolicyName in interface IPolicy
      Specified by:
      getPolicyName in class PolicyBase
    • getDescription

      @Stability(Stable) @Nullable public String getDescription()
      The description of the policy.
      Specified by:
      getDescription in interface IPolicy
      Specified by:
      getDescription in class PolicyBase
    • getValidationMode

      @Stability(Stable) @Nullable public PolicyValidationMode getValidationMode()
      The validation mode for the policy.
      Specified by:
      getValidationMode in interface IPolicy
      Specified by:
      getValidationMode in class PolicyBase