Skip to content

fix: sync e2e IAM policy and fix run eval flag#1092

Merged
jariy17 merged 5 commits intomainfrom
fix/e2e-iam-permissions
May 1, 2026
Merged

fix: sync e2e IAM policy and fix run eval flag#1092
jariy17 merged 5 commits intomainfrom
fix/e2e-iam-permissions

Conversation

@jariy17
Copy link
Copy Markdown
Contributor

@jariy17 jariy17 commented May 1, 2026

Summary

  • Syncs docs/policies/iam-policy-user.json fully with the live e2e-github-actions role — the doc was significantly out of date
  • Adds missing permissions that were causing e2e test failures:
    • bedrock-agentcore:CreateConfigurationBundle + CRUD (fixes config-bundle-eval-rec.test.ts 403s)
    • iam:CreateRole/DeleteRole/GetRole/PutRolePolicy/DeleteRolePolicy scoped to AgentCore-* (fixes HTTP gateway role creation in ab-test-target-based.test.ts)
    • bedrock-agentcore:StartBatchEvaluation, StartRecommendation + related Get/List actions (fixes 403s in batch eval and recommendation tests)
  • Fixes run eval CLI flag: test was passing --lookback but the correct flag is --days

Root cause

Several new post-deploy operations (config bundle sync, HTTP gateway IAM role creation, batch evaluation, recommendations) were added without updating the e2e role policy or the docs. The doc had also drifted significantly from the live role.

Test plan

  • config-bundle-eval-rec.test.ts — deploy warnings and 403s should clear
  • ab-test-target-based.test.ts — HTTP gateway creation should succeed
  • run eval test step — --days flag resolves the unknown option error

🤖 Generated with Claude Code

… HTTP gateways

- Add ConfigBundleManagement: CreateConfigurationBundle and related CRUD
  actions needed by post-deploy-config-bundles.ts
- Add HttpGatewayIamRoleManagement: iam:CreateRole/DeleteRole/GetRole/
  PutRolePolicy/DeleteRolePolicy scoped to arn:aws:iam::*:role/AgentCore-*
  needed by post-deploy-http-gateways.ts to create execution roles

Without these, config-bundle-eval-rec.test.ts and ab-test-target-based.test.ts
fail in CI with 403 authorization errors.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@jariy17 jariy17 requested a review from a team May 1, 2026 21:02
@github-actions github-actions Bot added size/s PR size: S agentcore-harness-reviewing AgentCore Harness review in progress labels May 1, 2026
@agentcore-cli-automation
Copy link
Copy Markdown

Thanks for adding these. I found two IAM actions that look missing for the HTTP gateway flow — without them the e2e test will still hit AccessDenied in the same ab-test-target-based path you're trying to fix.

1. Missing iam:TagRole

post-deploy-http-gateways.ts calls CreateRoleCommand with a Tags array (lines ~554–565):

new CreateRoleCommand({
  RoleName: roleName,
  AssumeRolePolicyDocument: trustPolicy,
  Description: ...,
  Tags: [
    { Key: 'agentcore:created-by', Value: 'agentcore-cli' },
    { Key: 'agentcore:project-name', Value: projectName },
    { Key: 'agentcore:http-gateway-name', Value: gatewayName },
  ],
})

Per IAM docs, attaching tags via CreateRole requires iam:TagRole on the caller in addition to iam:CreateRole. Without it, CreateRole will fail with AccessDenied even though iam:CreateRole is present.

This is also consistent with the docs/PERMISSIONS.md table, which already lists iam:TagRole as a required action for execution role creation.

2. Missing iam:PassRole

After creating the role, the code calls createHttpGateway(...) which POSTs to /gateways with roleArn in the body (src/cli/aws/agentcore-http-gateways.ts line 223). Passing a role ARN to an AWS service API requires iam:PassRole on the caller, scoped to that role.

This path is new — unlike runtime execution roles that are created by CloudFormation via the CDK execution role (which already has iam:PassRole in iam-policy-cfn-execution.json), HTTP gateway roles are now created/passed by the user credentials directly via SDK, so the user policy needs iam:PassRole too. docs/PERMISSIONS.md also lists this as a required action.

Suggested fix

Add both actions to the HttpGatewayIamRoleManagement statement (keeping the AgentCore-* resource scope):

{
  "Sid": "HttpGatewayIamRoleManagement",
  "Effect": "Allow",
  "Action": [
    "iam:CreateRole",
    "iam:DeleteRole",
    "iam:GetRole",
    "iam:PutRolePolicy",
    "iam:DeleteRolePolicy",
    "iam:TagRole",
    "iam:PassRole"
  ],
  "Resource": "arn:aws:iam::*:role/AgentCore-*"
}

Alternatively, if you prefer to avoid iam:TagRole, you could drop the Tags argument from the CreateRoleCommand call in post-deploy-http-gateways.ts (though losing the tags would hurt debuggability/attribution — I'd recommend the policy change instead).

You may want to manually test ab-test-target-based.test.ts end-to-end after applying the updated policy, since CreateRole-succeeds-without-tags is not obviously caught by CI unless the e2e role is updated first.

@github-actions github-actions Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.89% 8936 / 20830
🔵 Statements 42.17% 9485 / 22491
🔵 Functions 39.66% 1537 / 3875
🔵 Branches 39.82% 5769 / 14486
Generated in workflow #2331 for commit ba54415 by the Vitest Coverage Report Action

IAM policy (docs/policies/iam-policy-user.json):
- Add BatchEvalAndRecommendation: StartBatchEvaluation, StartRecommendation
  and related Get/List actions (already had ConfigBundle and HttpGateway IAM)

Test fix (e2e-tests/config-bundle-eval-rec.test.ts):
- run eval uses --days not --lookback; fix the flag name

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size/s PR size: S and removed size/s PR size: S labels May 1, 2026
Bring the documented policy fully in sync with what is deployed on the
e2e-github-actions role. Adds actions that were missing from the docs:
- InvokeAgentRuntimeForUser, InvokeAgentRuntimeCommand, InvokeModelWithResponseStream
- DeleteApiKeyCredentialProvider, ListApiKeyCredentialProviders
- Full AgentCore resource management (CreateAgentRuntime, gateways, memories, etc.)
- cloudformation:*, ssm:GetParameter(s), cloudformation:GetTemplate
- secretsmanager CRUD, cognito-idp for custom JWT e2e setup
- HarnessManagement + HarnessPassRole
- Kept ACCOUNT_ID placeholder for account-specific resources

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size/m PR size: M and removed size/s PR size: S labels May 1, 2026
@jariy17 jariy17 changed the title fix: add missing IAM permissions for config bundles and HTTP gateways in e2e policy fix: sync e2e IAM policy and fix run eval flag May 1, 2026
notgitika
notgitika previously approved these changes May 1, 2026
CreateRoleCommand passes Tags so iam:TagRole is required. After creation,
the role ARN is passed to createHttpGateway() which requires iam:PassRole
on the caller. Both scoped to AgentCore-* resource.

Caught by agentcore-cli-automation review on PR #1092.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels May 1, 2026
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels May 1, 2026
@notgitika notgitika self-requested a review May 1, 2026 22:19
@jariy17 jariy17 merged commit 78b3bd1 into main May 1, 2026
24 checks passed
@jariy17 jariy17 deleted the fix/e2e-iam-permissions branch May 1, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants