fix: pass aws_profile to boto3.Session when inferring Bedrock region#1413
Open
tianhaocui wants to merge 1 commit intoanthropics:mainfrom
Open
fix: pass aws_profile to boto3.Session when inferring Bedrock region#1413tianhaocui wants to merge 1 commit intoanthropics:mainfrom
tianhaocui wants to merge 1 commit intoanthropics:mainfrom
Conversation
_infer_region() creates a bare boto3.Session() without the profile_name argument, so it never reads the region configured for the specified AWS profile in ~/.aws/config. This causes AnthropicBedrock(aws_profile=...) to default to us-east-1 instead of using the profile's region. Pass aws_profile through to boto3.Session(profile_name=aws_profile) so the region is correctly inferred from the profile configuration. Fixes anthropics#892
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.
Fixes #892
Summary
_infer_region()creates a bareboto3.Session()without theprofile_nameargument, so it never reads the region configured for the specified AWS profile in~/.aws/config. This causesAnthropicBedrock(aws_profile=...)to default tous-east-1instead of using the profile's configured region.Changes
Pass
aws_profilethrough toboto3.Session(profile_name=aws_profile)in_infer_region(), and forwardaws_profilefrom bothAnthropicBedrock.__init__andAsyncAnthropicBedrock.__init__.4 lines changed across 3 call sites in
src/anthropic/lib/bedrock/_client.py.