feat: add ResourcePolicyClient for resource-based policy management#328
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #328 +/- ##
=======================================
Coverage ? 90.90%
=======================================
Files ? 43
Lines ? 4068
Branches ? 624
=======================================
Hits ? 3698
Misses ? 203
Partials ? 167
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7c2087d to
29f31fa
Compare
| from bedrock_agentcore._utils.endpoints import get_control_plane_endpoint | ||
|
|
||
|
|
||
| class ResourcePolicyClient: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I understand why having a separate client. Thank you for weighing both options. I'm fine with merging this client.
29f31fa to
5aaef48
Compare
|
rebase onto integ test changes. |
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:
Alternative Solutions
Direct passthrough to boto on client
Private Class Consumed by primitivates
Testing
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.