Skip to content

feat: add ResourcePolicyClient for resource-based policy management#328

Merged
Hweinstock merged 1 commit intoaws:mainfrom
Hweinstock:feat/resource-based-policies
Mar 13, 2026
Merged

feat: add ResourcePolicyClient for resource-based policy management#328
Hweinstock merged 1 commit intoaws:mainfrom
Hweinstock:feat/resource-based-policies

Conversation

@Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented Mar 12, 2026

Issue #, if available: N/A

Description of changes:

Problem

The SDK has no support for resource-based policies, which allow customers to control which principals can invoke and manage their Agent Runtime, Endpoint, and Gateway resources. This is useful for fine-grained cross-account access and OAuth authentication scenarios. Without SDK support, users must drop to raw boto3 calls.

Solution

Added ResourcePolicyClient in src/bedrock_agentcore/services/resource_policy.py — a thin wrapper around the 3 control plane APIs, following the existing IdentityClient pattern:

  • put_resource_policy(resource_arn, policy) — create/update (accepts dict or JSON str)
  • get_resource_policy(resource_arn) — get
  • delete_resource_policy(resource_arn) — delete

Alternative Solutions

Direct passthrough to boto on client

  • Pros: minimal code and logic to maintain.
  • Cons: provides little value over using boto directly. Ex. no serialization/deserialization, difficult to extend in future.

Private Class Consumed by primitivates

  • Pros: limits the number of classes we expose.
  • Cons: Requires manually wiring up resource based policies into each primitive we want to support it.

Testing

  • unit tests.
  • integ tests: Verifies e2e behavior. Setup additional RESOURCE_POLICY_TEST_ARN and
    RESOURCE_POLICY_TEST_PRINCIPAL secrets.(ran against my dev account).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@62fdc9a). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #328   +/-   ##
=======================================
  Coverage        ?   90.90%           
=======================================
  Files           ?       43           
  Lines           ?     4068           
  Branches        ?      624           
=======================================
  Hits            ?     3698           
  Misses          ?      203           
  Partials        ?      167           
Flag Coverage Δ
unittests 90.90% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Hweinstock Hweinstock force-pushed the feat/resource-based-policies branch 11 times, most recently from 7c2087d to 29f31fa Compare March 12, 2026 19:54
@Hweinstock Hweinstock marked this pull request as ready for review March 12, 2026 20:11
@Hweinstock Hweinstock requested a review from a team March 12, 2026 20:11
from bedrock_agentcore._utils.endpoints import get_control_plane_endpoint


class ResourcePolicyClient:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managing an agent runtime requires two clients: the existing runtime client and a resource policy client. Customers who need to attach resource policies to a runtime will need this additional client.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the tradeoff with this approach. If we hide the resource policy functionality behind other clients, the customers can manage an agent runtime with a single client, but we are responsible for wiring that up each time we want to add support for a new primitive or agentcore resource.

Alternatively, if we create a separate class the customer will need separate clients for the mentioned flow, but it allows for a more extendable and flexible design that doesn't require explicitly wiring up each consumer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why having a separate client. Thank you for weighing both options. I'm fine with merging this client.

jariy17
jariy17 previously approved these changes Mar 12, 2026
padmak30
padmak30 previously approved these changes Mar 13, 2026
@Hweinstock Hweinstock dismissed stale reviews from padmak30 and jariy17 via 5aaef48 March 13, 2026 14:52
@Hweinstock Hweinstock force-pushed the feat/resource-based-policies branch from 29f31fa to 5aaef48 Compare March 13, 2026 14:52
@Hweinstock
Copy link
Contributor Author

rebase onto integ test changes.

@Hweinstock Hweinstock merged commit 51e26c7 into aws:main Mar 13, 2026
17 of 18 checks passed
@Hweinstock Hweinstock deleted the feat/resource-based-policies branch March 13, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants