Bedrock: support cross-account AssumeRole credential provider#566
Open
amjosuesanchez wants to merge 1 commit into
Open
Bedrock: support cross-account AssumeRole credential provider#566amjosuesanchez wants to merge 1 commit into
amjosuesanchez wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds STS AssumeRole support to the Bedrock provider, enabling cross-account access to Bedrock models. This is the standard AWS pattern for workloads that run in one account but need to invoke Bedrock in another (e.g., an ECS task in account A assuming a Bedrock-invoker role in account B).
Tested in production with ECS Fargate workloads assuming cross-account roles.
Usage
When
assume_role_arnis set, the provider creates an STS client using the SDK's default credential chain (instance profile, ECS task role, etc.), assumes the target role, and passes the resulting temporary credentials to the Bedrock client. Credentials are memoized and automatically refreshed ~5 minutes before expiration.Approach
The implementation follows the same trait-based concern pattern used by
CreatesBedrockClient. No new Composer dependencies —aws/aws-sdk-php(already required) includesAws\Sts\StsClientandAws\Credentials\AssumeRoleCredentialProvider.Credential Resolution Priority
key)access_key_id+secret_access_key)assume_role_arn) — newAssumeRole is checked before
use_default_credential_providerbecause an explicit role ARN represents a stronger intent signal than the boolean flag — disabling default credentials should not silently ignore a configured role.Tests
Added 8 unit tests covering:
use_default_credential_provider: falseDoc: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-api.html