# PolicyProps

Properties for creating a Policy resource.

Used as props by: [Policy](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.Policy.html)

- Source: [`lib/policy/policy.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/policy/policy.ts#L22)
- Type last changed: v2.278.0-alpha.0 · 21 Nov 2026

## Example

TypeScript:

```ts
declare const policyEngine: agentcore.PolicyEngine;

// Option 1: Using definition property
const advancedPolicy = new agentcore.Policy(this, "AdvancedPolicy", {
  policyEngine: policyEngine,
  definition: 'permit(principal, action, resource) when { context.custom > 10 };',
  description: "Advanced policy with custom Cedar logic",
});

// Option 2: Using fromCedar() with statement property
policyEngine.addPolicy("CustomPolicy", {
  statement: agentcore.PolicyStatement.fromCedar(
    'forbid(principal, action, resource) when { resource.confidential == true };'
  ),
  description: "Custom policy from Cedar string",
});
```

Python:

```python
# policy_engine: agentcore.PolicyEngine

# Option 1: Using definition property
advanced_policy = agentcore.Policy(self, "AdvancedPolicy",
    policy_engine=policy_engine,
    definition="permit(principal, action, resource) when { context.custom > 10 };",
    description="Advanced policy with custom Cedar logic"
)

# Option 2: Using fromCedar() with statement property
policy_engine.add_policy("CustomPolicy",
    statement=agentcore.PolicyStatement.from_cedar("forbid(principal, action, resource) when { resource.confidential == true };"),
    description="Custom policy from Cedar string"
)
```

Java:

```java
PolicyEngine policyEngine;

// Option 1: Using definition property
Policy advancedPolicy = Policy.Builder.create(this, "AdvancedPolicy")
        .policyEngine(policyEngine)
        .definition("permit(principal, action, resource) when { context.custom > 10 };")
        .description("Advanced policy with custom Cedar logic")
        .build();

// Option 2: Using fromCedar() with statement property
policyEngine.addPolicy("CustomPolicy", AddPolicyOptions.builder()
        .statement(PolicyStatement.fromCedar("forbid(principal, action, resource) when { resource.confidential == true };"))
        .description("Custom policy from Cedar string")
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Agentcore.Alpha
PolicyEngine policyEngine;

// Option 1: Using definition property
var advancedPolicy = new Policy(this, "AdvancedPolicy", new PolicyProps {
    PolicyEngine = policyEngine,
    Definition = "permit(principal, action, resource) when { context.custom > 10 };",
    Description = "Advanced policy with custom Cedar logic"
});

// Option 2: Using fromCedar() with statement property
policyEngine.AddPolicy("CustomPolicy", new AddPolicyOptions {
    Statement = PolicyStatement.FromCedar("forbid(principal, action, resource) when { resource.confidential == true };"),
    Description = "Custom policy from Cedar string"
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2
var policyEngine PolicyEngine

// Option 1: Using definition property
advancedPolicy := agentcore.NewPolicy(this, jsii.String("AdvancedPolicy"), &PolicyProps{
	PolicyEngine: policyEngine,
	Definition: jsii.String("permit(principal, action, resource) when { context.custom > 10 };"),
	Description: jsii.String("Advanced policy with custom Cedar logic"),
})

// Option 2: Using fromCedar() with statement property
policyEngine.AddPolicy(jsii.String("CustomPolicy"), &AddPolicyOptions{
	Statement: agentcore.PolicyStatement_FromCedar(jsii.String("forbid(principal, action, resource) when { resource.confidential == true };")),
	Description: jsii.String("Custom policy from Cedar string"),
})
```

## Properties

- `definition`: string — Cedar policy statement. The authorization policy written in Cedar policy language.

  **Default:** Must provide either definition or statement

  Cedar supports permit and forbid rules with conditions.
  The statement will be wrapped in a PolicyDefinition structure internally.

  Pass the raw Cedar statement as a string. For example:
  - "permit(principal, action, resource);"
  - "permit(principal in Group::\"Admins\", action == Action::\"InvokeModel\", resource) when { context.environment == \"production\" };"

  You must specify either `definition` or `statement`, but not both.

- `description`: string — Optional description for the policy.

  **Default:** No description

  Maximum length of 4096.

- `policyEngine`: [IPolicyEngine](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.IPolicyEngine.html) (required) — The policy engine this policy belongs to.

  [disable-awslint:prefer-ref-interface]

- `policyName`: string — The name of the policy.

  **Default:** Auto-generated unique name

  Valid characters: a-z, A-Z, 0-9, _ (underscore)
  Must start with a letter, 1-48 characters
  Pattern: ^[A-Za-z][A-Za-z0-9_]*$

- `statement`: [PolicyStatement](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.PolicyStatement.html) — Type-safe Cedar policy statement built using PolicyStatement builder.

  **Default:** Must provide either definition or statement

  Use this for a type-safe, form-like API to build Cedar policies without
  writing raw Cedar syntax. The builder validates at synthesis time.

  You must specify either `definition` or `statement`, but not both.

- `validationMode`: [PolicyValidationMode](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.PolicyValidationMode.html) — Validation mode for the policy.

  **Default:** PolicyValidationMode.FAIL_ON_ANY_FINDINGS

  Controls how Cedar analyzer validation findings are handled.
