This service is in preview release and is subject to change.
Add your first policies to an AI agent
In this tutorial, you install AWS Greenlight, give it permissions, and add your first policies to an agent behind an Amazon Bedrock AgentCore gateway or in a Strands Box.
Time to complete: About 5 minutes to install. Then AWS Greenlight takes about 10 minutes to build your first proposal, plus the time you spend reviewing it.
Cost: You pay for the AWS resources that you use, such as your gateway, Amazon CloudWatch Logs, and an S3 bucket.
Topics
Prerequisites
Before you begin, complete Setting up AWS Greenlight for Agents.
Step 1: Install AWS Greenlight
Run the following command in a terminal.
curl -fsSL https://downloads.aws.com/aws-greenlight/plugins/LTS/latest/install.sh | bash
AWS Greenlight for Agents is AWS Content under the AWS Intellectual Property LicenseLICENSE file in each download has the license text, and THIRD-PARTY-NOTICES.md lists the third-party software that it uses.
The installer doesn’t need sudo. It shows you a plan and waits for you to press Return. Then it does the following:
-
Downloads AWS Greenlight, checks it against the SHA-256 checksum published with the release, and unzips it to
~/aws-greenlight-for-agents. -
Installs the tools that AWS Greenlight needs, if they’re missing: uv and the AWS CLI. It checks each download against a pinned SHA-256 checksum. The installer doesn’t install Rust or build anything.
-
Checks whether the Dogwood CLI 1.1.0 is installed. If it’s missing, the installer lists it as
[you install]in the plan. When it finishes, it prints the commands to install it. You run them yourself, as described in Install the Dogwood CLI. -
Checks whether
~/.local/binis on yourPATH. It never changes your shell’s startup files. If the folder isn’t on yourPATH, its last lines show the line to add,export PATH="$HOME/.local/bin:$PATH", and the file to add it to, such as~/.zshrc. -
Asks about each coding agent that it finds, and installs AWS Greenlight in each one that you choose.
The installer never changes your AWS configuration or credentials, and it passes none of your AWS_* variables to the tools that it downloads.
When the installer is done, check its last lines. If they show a line to add to your shell’s startup file, add it. Then open a new terminal window.
Install the Dogwood CLI
With the Dogwood CLI, AWS Greenlight checks each policy against your agent’s schema and explains it in plain language. The installer doesn’t install the Dogwood CLI, so you install version 1.1.0 yourself. If the Dogwood CLI is missing, the installer prints these same commands when it finishes.
This step needs a C compiler and Rust, which you set up in Setting up AWS Greenlight for Agents. To install the Dogwood CLI, complete the following steps.
-
Install Rust 1.97.1, the toolchain that the Dogwood CLI is built with.
rustup toolchain install 1.97.1 -
Build the Dogwood CLI and install it in
~/policy-builder-deps. Building takes a few minutes.cargo +1.97.1 install --locked --root ~/policy-builder-deps dogwood-cli@1.1.0If your
cargoisn’t rustup’s, such as one from a Linux distribution or Homebrew, leave out+1.97.1. To replace a Dogwood CLI that’s already in~/policy-builder-deps/bin, add--force. -
(Optional) To run
dogwoodwithout its full path, run the installer again. It links the Dogwood CLI into~/.local/bin. AWS Greenlight finds the Dogwood CLI in~/policy-builder-deps/binwithout the link.
Settings for your coding agent
Kiro – Start Kiro with kiro-cli chat. If you’ve set Kiro to use its v2 engine, start it with kiro-cli chat --v3 instead, because only v3 loads AWS Greenlight. Kiro asks before it runs each command. Don’t start Kiro with --trust-all-tools or run /tools trust-all, because then it runs AWS Greenlight’s approve and apply commands without asking. To always be asked before those commands, add the following to ~/.kiro/settings/permissions.yaml.
rules: - capability: shell match: - "*scripts/run project.approval approve*" - "*scripts/run agentcore.deploy apply*" - "*scripts/run strands_box.deploy apply*" - "*scripts/run sample.new_agent deploy*" effect: ask
If you use a custom Kiro agent, turn on installed powers for it. AWS Greenlight installs in Kiro as a power, and a custom agent loads installed powers only when its configuration sets includePowers to true. Add this field to your agent’s configuration file, ~/.kiro/agents/your-agent.json for a global agent or .kiro/agents/your-agent.json in the project.
{ "name": "your-agent", "includePowers": true }
For more information about custom agent configuration, see Agent configuration reference
Claude Code – You don’t need to change any settings. Start a new claude session. Claude Code asks before it runs each AWS Greenlight script. Approve it, and choose not to be asked again for that command. Claude Code still asks before each command that approves a policy set or changes what’s enforced on your agent. Allow it only if that’s what you chose. Don’t run AWS Greenlight in dontAsk or bypassPermissions mode.
Codex – By default, Codex blocks network access and only lets commands write inside your project. AWS Greenlight needs to call AWS and to write to uv’s cache. To allow this, add the following lines at the top of ~/.codex/config.toml, before any line that begins with [.
sandbox_mode = "workspace-write" [sandbox_workspace_write] network_access = true writable_roots = ["~/.cache/uv", "~/.aws/login"]
These settings apply to every command in the session, not only the ones that AWS Greenlight runs. They let commands reach the network and replace your cached aws login credentials. Don’t list ~/.aws instead, which would also let commands rewrite your AWS configuration. Only use these settings in a session that you trust with your AWS profile.
With these settings, Codex runs commands without asking, including the ones that approve your policies and turn them on. To be asked first, add the following to ~/.codex/rules/default.rules. Don’t start Codex with --yolo or --approve-for-me.
prefix_rule( pattern = ["sh", "scripts/run", "project.approval", "approve"], decision = "prompt", justification = "AWS Greenlight approves a policy set", ) prefix_rule( pattern = ["sh", "scripts/run", ["agentcore.deploy", "strands_box.deploy"], "apply"], decision = "prompt", justification = "AWS Greenlight changes what is enforced on your target", ) prefix_rule( pattern = ["sh", "scripts/run", "sample.new_agent", "deploy"], decision = "prompt", justification = "AWS Greenlight deploys the refund sample's stack", )
Then start a new Codex session.
Step 2: Check the install
Run the following command.
~/policy-builder-deps/bin/dogwood --version
The command shows the Dogwood CLI version, dogwood 1.1.0. If you ran the installer again after you installed the Dogwood CLI, it linked dogwood into ~/.local/bin, so dogwood --version works too when ~/.local/bin is on your PATH.
The installer’s last lines list each coding agent that it installed AWS Greenlight in. To check later, run claude plugin list in Claude Code or codex plugin list in Codex, and look for greenlight-for-agents@aws-greenlight. In Kiro, run ls ~/.kiro/powers/installed/greenlight-for-agents.
Step 3: Give your AWS profile permissions
AWS Greenlight signs its AWS calls with your AWS profile. The profile needs two AWS Identity and Access Management (IAM) policies:
-
read lets AWS Greenlight read your gateway and your agent’s logs, run its checks, and create the S3 bucket for test results if you ask it to.
-
enforce lets AWS Greenlight add and remove its policies on your gateway, switch the policy engine’s mode, put the gateway’s Amazon CloudWatch dashboard, and run the network check.
AWS Greenlight prints both policies for you, filled in with your own details. Replace the example values in the following commands, then run the commands for your agent.
For an AgentCore gateway, you need the gateway’s ID and the ARN of its role. To find the ID, run aws bedrock-agentcore-control list-gateways --profile your-profile. To find the role, run the following command.
aws bedrock-agentcore-control get-gateway --gateway-identifier your-gateway-id --query roleArn --output text --profile your-profile
Then print the policies.
cd ~/aws-greenlight-for-agents/plugins/greenlight-for-agents/skills/agent-policies sh scripts/run aws.permissions policy --target-type agentcore \ --account 111122223333 --region us-east-1 \ --gateway-id your-gateway-id \ --gateway-role arn:aws:iam::111122223333:role/your-gateway-role > ~/greenlight-policies.json
For a Strands Box, run the following command. Leave out --logs-bucket if the box keeps its decision log on your computer.
cd ~/aws-greenlight-for-agents/plugins/greenlight-for-agents/skills/agent-policies sh scripts/run aws.permissions policy --target-type strands-box \ --account 111122223333 --region us-east-1 \ --logs-bucket your-logs-bucket > ~/greenlight-policies.json
If you already have an S3 bucket for test results, add --results-bucket your-bucket-name to the command. If you leave it out, read includes the permission to create one bucket, named greenlight-results-account-id-region.
The policies cover every policy engine and log group in the account and Region. The file’s notes say so. To narrow them to your gateway’s, add --policy-engine-id your-policy-engine-id and --log-group your-log-group to the command.
Attach both policies to the IAM role that your profile signs in as. To see which role, run aws sts get-caller-identity --profile your-profile.
jq .read ~/greenlight-policies.json > ~/greenlight-read.json jq .enforce ~/greenlight-policies.json > ~/greenlight-enforce.json aws iam put-role-policy --role-name your-role --policy-name greenlight-read \ --policy-document file://$HOME/greenlight-read.json --profile your-profile aws iam put-role-policy --role-name your-role --policy-name greenlight-enforce \ --policy-document file://$HOME/greenlight-enforce.json --profile your-profile
For an IAM user, use aws iam put-user-policy --user-name your-user instead. If jq isn’t installed, ask your coding agent to split the file.
For a gateway, to run the network check in Step 6, also attach AWS’s managed policy AmazonVPCNetworkAccessAnalyzerFullAccessPolicy to the same role.
aws iam attach-role-policy --role-name your-role \ --policy-arn arn:aws:iam::aws:policy/AmazonVPCNetworkAccessAnalyzerFullAccessPolicy --profile your-profile
In a production account, you can attach enforce to a separate role with its own profile instead. The section "Two policies: reading and enforcing" in ~/aws-greenlight-for-agents/plugins/greenlight-for-agents/README.md explains how. Don’t use an administrator role.
Step 4: Generate suggested policies for your agent
What happens when you say govern my agent
AWS Greenlight works in six steps: Agent, Sources, Clarifications, Decisions, Approval, and Enforcement. For each step, it opens an HTML page in your browser, with the steps shown across the top.
You answer its questions in your coding agent. The HTML page shows what’s behind each question, such as the passages from your documents and the recorded calls that a policy would deny. On the Clarifications and Decisions pages, you can also choose your answers in the browser. The page then gives you a reply to copy into your coding agent.
Reply with your answers only. If your reply also asks a question, AWS Greenlight answers the question and records none of your answers. Then it asks again.
You can stop at any time. To continue, start your coding agent in the same folder and say govern my agent again. It reuses your saved account, agent, and bucket, and asks again what to learn from and how far back to look. To use another profile, say change. A folder keeps one agent. To govern another agent, start in a new folder. If you stopped in the middle of building a proposal, it first asks whether to continue it or start over.
Start a session
-
Choose a folder for the project. This can be your agent’s code repository or an empty folder. Use one folder for each agent that you govern. AWS Greenlight saves its work in a
.greenlightfolder there.AWS Greenlight can learn from two kinds of documents: files in this folder, such as documented procedures and rules, and AWS Context, if your company uses it. It reads local files only from inside this folder, so copy in the ones that you want it to use. For a gateway, it can also read your agent’s logs from other AWS accounts. You choose which sources to use.
-
Start your coding agent in that folder, and type the following.
govern my agent
Answer the setup questions (Agent and Sources)
First, AWS Greenlight asks which agent to govern:
-
Your AWS account. It lists up to three AWS profiles, in this order: the one this project uses, the one in
AWS_PROFILE,default, then others. If your profile isn’t listed, type its name. It also asks for a Region if your profile doesn’t set one. -
The type of agent. AgentCore Gateway, Strands Box, or No Target. Choose No Target to write and check policies without deploying them.
-
Which gateway or box. It lists up to four gateways that it can govern. These are gateways that are ready, have a policy engine, and have tools that it can read. If yours isn’t listed, type its name, ID, or ARN. If the folder holds an AgentCore CLI project, its gateway is listed near the top. For a box, it looks for the box’s
box.tomlfile in the project folder, or you can give its path. It also asks where the box’s decision log is. For a gateway or a box, it might also ask which AgentCore Runtime runs your agent, for the stack check in Step 6. In an AgentCore CLI project’s folder, it lists the project’s Runtimes. You can also choose Type its ARN or Skip.
Then it asks what to learn from:
-
Your sources. Past tool calls, documents, or both, and which documents to use.
-
How far back to look. You can type any window from 1 minute to 30 days.
-
An S3 bucket for test results. Choose one of your buckets, or let AWS Greenlight create one.
Each question shows only a few choices. In Kiro and Codex, questions come as numbered lists. Answer with a number. To skip the questions, say what you want in your first message, as in the following example.
generate policies for gateway my-gateway in us-west-2 from its logs of the past week and ./docs/refund-procedure.pdf, with profile your-profile
It then asks only for what you left out. Before it starts, it shows your choices so that you can confirm them.
Settle what’s unclear (Clarifications)
AWS Greenlight lists what’s unclear in your sources on the Clarifications page in your browser, with the passages that each item came from. Most items have a recommended answer. Keep it or choose another. When AWS Greenlight can’t choose, it marks the item Needs your call. There are three kinds of item:
-
Conflict – Two sources disagree. For example, one procedure says that an approval must come earlier in the same ticket, and another says within the last 24 hours. You choose which one the policies follow.
-
Assumption – A source is ambiguous, such as "shortly before the reset." AWS Greenlight suggests what it means. Approve the suggestion or give your own.
-
The agent’s word – A rule depends on a value that only the agent supplies, and that no tool call returns. For example, the customer reads out a receipt number, and the agent types it into the refund call. The policies can check that a number is there, but not that it’s real. You choose one of the following:
-
Trust the agent. – AWS Greenlight enforces the rule. It stops the agent if it leaves out the receipt number, but not if it makes one up. These policies are marked Trusts the agent.
-
Don’t trust the agent. – AWS Greenlight enforces only the part that needs no trust. For example, it stops a refund with no receipt number at all. The report lists the rest of the rule with the change that would let it be checked, such as a tool that looks up the receipt.
-
Ask me for each requirement. – AWS Greenlight shows you each rule like this, and you choose.
-
Sometimes two sources are copies or versions of the same procedure, and one of them says that it’s out of date, such as a draft or a superseded version. AWS Greenlight uses the current one, and lists the item as settled so that you can see which copy it used.
When every item is settled, reply with only Approve all. If an item still needs your call, choose Change something and answer it first. If your reply adds a question or other words, AWS Greenlight answers them and shows the choice again, without approving anything.
Your answers decide how AWS Greenlight writes the policies.
Review the proposal (Decisions)
AWS Greenlight then writes the policies and checks them. This takes about 10 minutes. It adds a proposed policy without asking you when the policy comes from your sources and doesn’t deny anything your agent already did. It asks you about any policy that would deny calls your agent already made, that it learned only from your agent’s calls, or that relies on a value it guessed, such as a limit. Rules that it can’t enforce aren’t asked about. The report lists them as Not enforceable.
For each policy that it asks about, it shows a scenario on the Decisions page that the policy would deny, usually from your agent’s recorded calls, such as a password reset with no identity check first. It asks Deny it or allow it?
For each scenario, choose one of the following:
-
Deny it – The agent shouldn’t do this, so keep the policy. The page shows how many recorded calls the policy would deny.
-
Allow it – The agent is allowed to do this, so the policy isn’t added.
-
Not sure – The policy is left out for now, and the Approval step lists it so that you can come back to it.
-
Change the policy – Say in your own words how the policy should differ, and AWS Greenlight checks the new version again.
To change your answers before you approve, type decide.
Read the report (Approval)
Nothing goes on your agent until you approve it. AWS Greenlight proposes policies and verifies what it can, but it can misread what you meant. Read the report closely. Check that each policy matches your intent, and decide what to do about each rule that it couldn’t enforce.
The report shows the policy set before you approve it. It has four tabs:
-
Overview – What the set was built from, how many policies it adds to the ones already on your gateway, and what to review.
-
Policies – Each policy, with what it does, the policy in Dogwood, and where it came from.
-
Properties – The claims that AWS Greenlight checked across every possible call, such as "the agent never resets a password unless that account’s identity was verified earlier in the same incident." Each one shows the result, the assumptions that it relies on, and what it doesn’t cover. Open Exact check to see the condition in Dogwood and the gateway that it was checked on. Each result is Verified, Verified, assuming, Verified, not replayed, Holds only for these spellings, Not verified, or Inconclusive. For what each means, see Limitations of AWS Greenlight for Agents.
-
Requirements – Each rule found in your sources, and whether the set enforces it. Each rule has one of the following statuses:
-
In proposal – A policy in the set enforces it. For an approved version, this reads In v1, In v2, and so on.
-
Not enforced – The policies don’t fully hold the rule. A check found a sequence of calls that the rule forbids but the policies allow.
-
Not in proposal – Only policies that you left out of the set enforce it.
-
Not enforceable – No policy can enforce it, usually because no tool call shows the facts that the rule needs, or because the rule is about what free text does, such as an SQL query or a command line.
-
From a dropped source – It came from a source that Clarifications left out when it settled an item, such as an older copy of a document.
For a rule that isn’t enforceable, the report says what would make it enforceable. For example, take a rule that the agent never changes data, for a tool that runs any SQL query. A policy can’t reliably read the query text, so the report suggests giving the tool a read-only database user. When a policy enforces part of a rule, the report names it.
-
The Policies tab shows each policy in Dogwood. For example, the following policy requires an identity check before a password reset. It denies reset_password unless, within the last 24 hours of the same session, verify_identity returned verified: true for the same user.
forbid (principal, action == AgentCore::Action::"helpdesk___reset_password", resource is AgentCore::Gateway) unless temporal { formerly within 24h AgentCore::Action::"helpdesk___verify_identity"::response{ input.user_name: context.input.user_name, output.verified: true, eventResource: resource } };
The summary, the report, and each answer to a check end with a note about the analysis’s limits, such as how it handles decimal values with more than 4 decimal places. For details, see Limitations of AWS Greenlight for Agents.
Check the proposal
Before you approve, ask about the cases that matter most to you. AWS Greenlight answers from the proposed policies.
check: can the agent ever issue a refund without a manager's approval? what happens if the agent refunds $2,000 to order 1234 with no approval?
A question about whether something can happen is checked across every possible call, and the answer is one of the check results in Limitations of AWS Greenlight for Agents. A sequence of calls that you describe is replayed as you wrote it, and the answer is Allowed, Denied at call n, or Not decided at call n. You can ask the same questions after you turn the policies on.
Step 5: Approve the policies
When the report looks right, type approve. AWS Greenlight shows what approving does and asks you to confirm. The choices are Approve, Check something, and Make changes, plus Decide scenario n first if a scenario is still unanswered. Choose Approve by its number or its label alone. If you add words of your own, such as "approve, but show me the diff first," AWS Greenlight answers them and asks again, without approving anything.
Before it saves, AWS Greenlight might ask about rounding. The gateway rounds each amount to 4 decimal places, so a call a little over a limit, such as USD $500.00004 on a USD $500.00 cap, can get through. Choose Keep the cap to keep the limit as written, and the version records the gap. Choose Deny 500 or more to close the gap, which also denies a call of exactly 500. Choose Make changes to save nothing and keep working. It asks once for each limit.
AWS Greenlight saves the policies as the next version, version 1 the first time. Approving doesn’t turn them on.
Step 6: Turn the policies on
How you turn policies on depends on whether your agent uses an AgentCore gateway or a Strands Box. To undo the last change at any time, type roll back.
On an AgentCore gateway: log only first
In log only mode, the gateway records which calls a policy would deny, but it doesn’t deny them.
-
Type
enforce it in log only, and choose Log only (Recommended). The other choices are the following:-
Enforce – Starts denying right away.
-
Log only, whole engine – Puts every policy on the engine in log only, including policies that AWS Greenlight didn’t write.
-
Choose per policy – Lets you choose the mode of each new or changed policy.
-
-
Let your agent work as usual. Then type
what would it have denied? -
If the results look right, type
promoteand choose Enforce. The gateway now denies any call that breaks a policy. To see which policy denied a call, askwhat did it deny?To wait instead, choose Keep log only.
If the gateway’s policy engine is itself in log only mode, the gateway denies nothing until you switch the engine to enforce. AWS Greenlight tells you when this is the case and offers to switch it.
If your gateway also passes requests through to an HTTP endpoint, such as an AgentCore Runtime, AWS Greenlight leaves those requests to you. A raw request has no tool name or inputs to check, so the only policy it could write would allow every request. Once the engine enforces, the gateway denies those requests unless you add a policy of your own that allows the callers and paths that you choose. AWS Greenlight warns you before this happens.
Check your agent’s stack (AgentCore gateway only)
After your policies are on the gateway, AWS Greenlight offers to check the rest of your agent’s stack. It asks first, and it changes nothing in the stack.
-
Permissions check – Your policies control which tool calls the gateway allows, but your agent’s roles can also reach AWS directly, outside the gateway. This check compares the roles of your AgentCore Runtime and gateway with the permissions that AgentCore recommends, using IAM Access Analyzer. It shows where a role allows more than AgentCore needs, so that you can tighten it. It only reads.
-
Network check – If your Runtime can reach the internet or other networks directly, your agent can get around the gateway and its policies. This check uses Network Access Analyzer to find every path in or out beyond AgentCore’s recommended private setup. It takes a few minutes. It creates two Network Access Analyzer queries in your account, one for ingress and one for egress. They’re saved as Network Access Scopes, tagged with the Runtime’s ID, and reused while the Runtime’s network stays the same.
AWS Greenlight asks which Runtime to check. In an AgentCore CLI project’s folder, it offers the project’s Runtime first. Each check lists the first 10 findings and offers to show more. It shows up to 20, and saves the full list in the project’s .greenlight/access-analysis/last.json file. The network check signs in with your enforce profile if you use one, or with your profile if you don’t. To check again later, for example after you change the stack’s roles or network, ask AWS Greenlight to check your stack. For what each check can’t see, see Limitations of AWS Greenlight for Agents.
In a Strands Box
A Strands Box has no log only mode.
-
Type
enforce, and choose Enforce now, or Not now to wait. AWS Greenlight writes the policies into a marked block of the box’s policy file,policy.dw. The rest of the file stays the same. If the box has no policy file yet, AWS Greenlight asks before it creates one. -
The box enforces the policies from the next run that loads the file. On AgentCore Runtime, that’s after you redeploy your agent with
agentcore deploy. After your agent has worked for a while, typewhat did it deny?AWS Greenlight reads the answer from the box’s decision log.
What you’ve built
You now have the following:
-
Your policies, enforced. On a gateway, they’re named starting with
pb_. If your gateway also has a model target, which lets your agent call its AI model through the gateway, AWS Greenlight adds a policy named starting withpbmc_that allows those calls. Without it, your agent’s own model calls would be denied once the engine enforces. In a box, your policies are in the marked block ofpolicy.dw. -
Version 1 of your policies, a report, and a log of each call to the AWS Greenlight service. These are in the project’s
.greenlightfolder. -
For a gateway, an Amazon CloudWatch dashboard named
PolicyBuilder-gateway-id. It updates after each change. Amazon CloudWatch charges for each dashboard after the first three in an account.
Next steps
To build on your first policies, try the following:
-
Add a rule in your own words:
add a policy: a refund needs an approval first -
Learn from more documents:
learn policies from my agent’s logs for the past day and the SOP at ./docs/sop.md -
For common issues, see Troubleshooting AWS Greenlight for Agents. To remove AWS Greenlight, see Clean up AWS Greenlight for Agents.