feat(bedrock-agentcore): add grantInvokeWithWebSocketStream method to Runtime #37508
feat(bedrock-agentcore): add grantInvokeWithWebSocketStream method to Runtime #37508
Conversation
… Runtime Add `grantInvokeWithWebSocketStream` to `IBedrockAgentRuntime` and `RuntimeBase` to grant `bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream` permission, enabling WebSocket stream invocation of AgentCore Runtimes. Closes aws#37495
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Features must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
✅ A exemption request has been requested. Please wait for a maintainer's review.
|
Exemption Request: the change only adds a different IAM action string to an existing grant pattern. |
pahud
left a comment
There was a problem hiding this comment.
Thanks for the clean PR @mazyu36 — the implementation is consistent with existing grant patterns and test coverage looks solid. A couple of suggestions for the maintainers to consider:
- JSDoc on grantInvoke
One thing I noticed is that grantInvoke doesn't mention it excludes WebSocket stream permissions. This is essentially what caused #37495 — users call grantInvoke expecting full access, then hit silent auth failures when using WebSocket. It might be worth updating the JSDoc to call this out explicitly, something like:
/**
* Permits an IAM principal to invoke this runtime via HTTP and on behalf of a user.
* Grants both InvokeAgentRuntime and InvokeAgentRuntimeForUser permissions.
*
* NOTE: This does not grant WebSocket stream permissions.
* Use {@link grantInvokeWithWebSocketStream} or
* {@link grantInvokeWithWebSocketStreamForUser} for WebSocket access.
*
* @param grantee The
* principal to grant access to
*/
- Idea: grantInvokeAll() convenience method
With this PR, users who want full invoke access would need to call multiple grant methods. A grantInvokeAll() that covers all four actions in one call could be a nice DX improvement. Just a thought — happy to leave this to the maintainers to decide if it's worth the added surface area.
Overall this looks good to me 👍
…ket stream permissions
Issue # (if applicable)
Closes #37495
Reason for this change
grantInvokedoes not grantbedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream, so roles cannot invoke AgentCore Runtimes via WebSocket stream.Description of changes
Add two new grant methods to
IBedrockAgentRuntimeandRuntimeBase:grantInvokeWithWebSocketStream— grantsbedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamgrantInvokeWithWebSocketStreamForUser— grantsbedrock-agentcore:InvokeAgentRuntimeWithWebSocketStreamForUserThis follows the same pattern as the existing
grantInvokeRuntime/grantInvokeRuntimeForUsermethods, and is consistent with how CDK separates invocation channels (e.g. Lambda'sgrantInvokevsgrantInvokeUrl, API Gateway v2'sgrantManageConnections).grantInvokeis intentionally left unchanged — users who need WebSocket stream access can call the new methods explicitly.References:
Description of how you validated changes
grantInvokeWithWebSocketStream: permission grant, imported runtime, Grant objectgrantInvokeWithWebSocketStreamForUser: permission grant, imported runtime, Grant objectChecklist
grantInvokeWithWebSocketStreamandgrantInvokeWithWebSocketStreamForUserBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license