Feature: Support for access aws bedrock through role arn directly and retrieve the AKSK from boto3.Session directly
Currently, if we want to access the aws bedrock through role arn, we should
bedrock_role="arn:aws:iam::xxxx:role/bedrock-access-role"
credentials = boto3.client('sts').assume_role(RoleArn=bedrock_role,RoleSessionName='assume-role')
client = AnthropicBedrock(aws_region="us-west-2", aws_access_key=credentials['Credentials']['AccessKeyId'], aws_secret_key=credentials['Credentials']['SecretAccessKey'])
Should we support access aws bedrock through role arn directly? such as
client = AnthropicBedrock(aws_region="us-west-2", aws_role_arn="arn:aws:iam::xxxx:role/bedrock-access-role")
Another feature is that we could get the AKSK and region from boto3.Session directly, and those data from the credential file under the default .aws folder.
c= boto3.Session()
cr=c.get_credentials().get_frozen_credentials()
cr.access_key
cr.secret_key
c.region_name
If one of them could be approved, May I push the related PR?
Hey @richzw — sorry for the long delay here. Both halves of this are covered by the aws_profile argument that shipped in v0.35.0: pointing it at a profile with role_arn/source_profile makes boto3 do the assume-role for you, and when no explicit keys are passed the default boto3 session chain already resolves credentials from ~/.aws.
# ~/.aws/config: [profile bedrock-assume] role_arn = ... / source_profile = ...
client = AnthropicBedrock(aws_region="us-west-2", aws_profile="bedrock-assume")