Create a policy engine
A policy engine is a collection of policies that evaluates and authorizes agent tool calls. When associated with a gateway, the policy engine intercepts all agent requests and determines whether to allow or deny each action based on the defined policies.
Prerequisites
Before creating a policy engine, set up a gateway. For more information, see Set up an Amazon Bedrock AgentCore gateway.
Create a policy engine
The following shows how to create a policy engine.
A policy engine name must match [A-Za-z][A-Za-z0-9_]* and be at most 48 characters: it starts with a letter,
and after that only letters, digits, and underscores are allowed. Hyphens are not valid in a name. Use
my_policy_engine, not my-policy-engine. The same rule applies to policy names. With the AgentCore CLI, the
deployed engine name is <project>_<target>_<name>, and that full name must be at most 48 characters.
Example
Identifiers you need afterwards
Creating an engine returns two identifiers, and they are not interchangeable:
-
policyEngineId -
Used by every policy operation:
CreatePolicy,ListPolicies,UpdatePolicy, andDeletePolicy. It looks likemy_policy_engine-a1b2c3d4e5: the engine name, plus a generated ten-character suffix. Passing an ARN where an ID is expected is rejected as a validation error. The--engineoption ofagentcore add policyandagentcore remove policytakes the engine name from the project instead. An engine that the AgentCore CLI deploys is named<project>_<target>_<name>. -
policyEngineArn -
Used to attach the engine to a gateway, as
policyEngineConfiguration.arnonCreateGatewayorUpdateGateway, alongside amodeofLOG_ONLYorENFORCE. The AgentCore CLI resolves this for you when you pass--attach-to-gateways.
For more information about creating policies, see Create a policy. For attaching an engine and switching modes, see Policy enforcement modes.