Skip to content

feat: Add AWS_PROFILE as an option to AWS Bedrock #2623

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wsargent
Copy link
Contributor

@wsargent wsargent commented May 14, 2025

Please describe the purpose of this pull request.

The AWS Bedrock provider currently doesn't have access to set up using the AWS_PROFILE configuration. This PR adds the functionality through boto.

How to test

You'll want to set up an AWS profile and run this code through there. The docs are pretty good about the set up:

# In ~/.aws/config
[profile my-sso-profile]
sso_start_url = https://my-sso-portal.awsapps.com/start
sso_region = us-east-1
sso_account_id = 123456789011
sso_role_name = readOnly

and then

import boto3

session = boto3.Session(profile_name='my-sso-profile')
s3_client = session.client('s3')

Have you tested this PR?

I have not, and this PR was partially originated by Jetbrains Junie -- you should verify it before merging.

@wsargent wsargent force-pushed the aws-bedrock-profile branch from 376dd82 to d82113c Compare May 14, 2025 05:09
@@ -91,6 +91,7 @@ class ModelSettings(BaseSettings):
aws_access_key: Optional[str] = None
aws_secret_access_key: Optional[str] = None
aws_region: Optional[str] = None
aws_profile: Optional[str] = None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add aws profile

bedrock = boto3.client("bedrock", region_name=region_name)
# If AWS_PROFILE is set, use it to create the session
if model_settings.aws_profile:
session = boto3.Session(profile_name=model_settings.aws_profile)
Copy link
Contributor Author

@wsargent wsargent May 14, 2025

Choose a reason for hiding this comment

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

bedrock = boto3.client("bedrock", region_name=region_name)
# If AWS_PROFILE is set, use it to create the session
if model_settings.aws_profile:
session = boto3.Session(profile_name=model_settings.aws_profile)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wsargent wsargent marked this pull request as ready for review May 14, 2025 15:52
@wsargent wsargent changed the title Add AWS_PROFILE as an option to AWS Bedrock feat: Add AWS_PROFILE as an option to AWS Bedrock May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant