Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support to fetch aws region from aws config file .aws/config #537 #539

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/anthropic/lib/bedrock/_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import os
import boto3
from typing import Any, Union, Mapping, TypeVar
from typing_extensions import Self, override

Expand Down Expand Up @@ -116,6 +117,8 @@ def __init__(

self.aws_access_key = aws_access_key

session = boto3.Session()
aws_region = session.region_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost what we want! Ideally we'd want to set aws_region in order of specificity:

  1. specific region passed as argument
  2. specific region passed as environment variable
  3. specific region within config
  4. default to us-east-1

however, as written in this PR, this would be:

  1. specific region within config
  2. specific region passed as argument
  3. specific region passed as environment variable
  4. default to us-east-1

if you could correct the ordering of assignment, that would be wonderful.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JDKardia, I fixed the issue here at #669, please review and merge

if aws_region is None:
aws_region = os.environ.get("AWS_REGION") or "us-east-1"
self.aws_region = aws_region
Expand Down
Loading