$npx -y skills add aws/agent-toolkit-for-aws --skill agents-hardenUse when preparing your agent for production — IAM scoping, inbound auth (JWT, SigV4), secrets management, cold start optimization, session lifecycle, rate limiting, input validation, and quota guidance. Triggers on: "production checklist", "harden agent", "production ready", "se
| 1 | # harden |
| 2 | |
| 3 | Prepare your AgentCore agent for production — security, reliability, and performance. |
| 4 | |
| 5 | ## When to use |
| 6 | |
| 7 | - You're about to take an agent to production |
| 8 | - You want a checklist of what to review before launch |
| 9 | - You want to restrict who can call your agent |
| 10 | - You want to scope down IAM permissions from the defaults |
| 11 | - You're hitting throttling or quota errors (loads [`references/limits.md`](references/limits.md)) |
| 12 | - You need to tune session lifecycle for your workload |
| 13 | - You're running long-running background work in your agent |
| 14 | |
| 15 | ## Input |
| 16 | |
| 17 | No arguments required. The skill reads your project config and produces a checklist with specific findings for your project. |
| 18 | |
| 19 | ## Process |
| 20 | |
| 21 | ### Step 0: Verify CLI version |
| 22 | |
| 23 | Run `agentcore --version`. This skill requires v0.9.0 or later. If the version is older, tell the developer to run `agentcore update` before proceeding. |
| 24 | |
| 25 | ### Step 1: Read the project |
| 26 | |
| 27 | Read `agentcore/agentcore.json` to understand: |
| 28 | |
| 29 | - What resources are configured (memory, gateway, credentials, evaluators) |
| 30 | - What framework is being used |
| 31 | - What network mode is configured (PUBLIC or VPC) |
| 32 | |
| 33 | ### Step 2: Run through the checklist |
| 34 | |
| 35 | Work through each category and report findings specific to the project. |
| 36 | |
| 37 | --- |
| 38 | |
| 39 | ## IAM: Scope down permissions |
| 40 | |
| 41 | The auto-created execution role has broad Bedrock access (`arn:aws:bedrock:*::foundation-model/*`). For production, scope it to the specific models your agent uses. |
| 42 | |
| 43 | **Check the current execution role:** |
| 44 | |
| 45 | ```bash |
| 46 | agentcore status --json | jq -r '.runtimes[0].executionRoleArn' |
| 47 | ``` |
| 48 | |
| 49 | **Recommended production Bedrock policy:** |
| 50 | |
| 51 | ```json |
| 52 | { |
| 53 | "Effect": "Allow", |
| 54 | "Action": [ |
| 55 | "bedrock:InvokeModel", |
| 56 | "bedrock:InvokeModelWithResponseStream" |
| 57 | ], |
| 58 | "Resource": [ |
| 59 | "arn:aws:bedrock:<REGION>::foundation-model/anthropic.claude-sonnet-4-5-20250929-v1:0" |
| 60 | ] |
| 61 | } |
| 62 | ``` |
| 63 | |
| 64 | Replace the resource ARN with the specific model(s) your agent uses. |
| 65 | |
| 66 | **ECR access:** Scope to your specific repository: |
| 67 | |
| 68 | ```json |
| 69 | { |
| 70 | "Effect": "Allow", |
| 71 | "Action": ["ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer"], |
| 72 | "Resource": "arn:aws:ecr:<REGION>:<YOUR_ACCOUNT_ID>:repository/bedrock-agentcore-<AGENT_NAME>-*" |
| 73 | } |
| 74 | ``` |
| 75 | |
| 76 | **Trust policy:** Verify the execution role's trust policy is scoped to your account: |
| 77 | |
| 78 | ```json |
| 79 | { |
| 80 | "Principal": {"Service": "bedrock-agentcore.amazonaws.com"}, |
| 81 | "Action": "sts:AssumeRole", |
| 82 | "Condition": { |
| 83 | "StringEquals": {"aws:SourceAccount": "<YOUR_ACCOUNT_ID>"}, |
| 84 | "ArnLike": {"aws:SourceArn": "arn:aws:bedrock-agentcore:<REGION>:<YOUR_ACCOUNT_ID>:*"} |
| 85 | } |
| 86 | } |
| 87 | ``` |
| 88 | |
| 89 | **Runtime resource-based policies** (API-only): For fine-grained control over which principals can invoke your runtime — beyond what IAM roles and JWT auth provide — use `PutAgentRuntimeResourcePolicy` via boto3. This is not exposed in the CLI or `agentcore.json`. Use the `awsknowledge` MCP server if available to look up the current API shape. |
| 90 | |
| 91 | --- |
| 92 | |
| 93 | ## Shell Access: Scope `InvokeAgentRuntimeCommand` separately |
| 94 | |
| 95 | If your project uses `InvokeAgentRuntimeCommand` (see [`agents-build/references/integrate.md`](../agents-build/references/integrate.md)), audit its IAM permissions separately from `InvokeAgentRuntime`. The two actions have different blast radii: `InvokeAgentRuntimeCommand` is arbitrary shell execution inside a live microVM with the runtime's full execution role — callers can read/write the filesystem, reach any network resource the agent can reach, and access the execution role's credentials. |
| 96 | |
| 97 | **Check which principals have the permission:** |
| 98 | |
| 99 | ```bash |
| 100 | # List customer-managed policies in your account, then inspect each for InvokeAgentRuntimeCommand |
| 101 | aws iam list-policies --scope Local \ |
| 102 | --query 'Policies[*].[PolicyName, Arn, DefaultVersionId]' \ |
| 103 | --output table |
| 104 | # Then for each policy of interest: |
| 105 | aws iam get-policy-version \ |
| 106 | --policy-arn <POLICY_ARN> \ |
| 107 | --version-id <VERSION_ID> \ |
| 108 | --query 'PolicyVersion.Document' |
| 109 | ``` |
| 110 | |
| 111 | Alternatively, use the |