Skip to content

Access keys and secrets are not getting passed when creating the session #35

@rajib76

Description

@rajib76

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

0.1.1

Python Version

3.11

Operating System

windows

Installation Method

pip

Steps to Reproduce

Although, I have the keys and secret in .env. I am getting "Your account is not authorized to invoke this API operation."

Below is the code I am running

boto_session = boto3.session.Session(aws_access_key_id=AWS_ACCESS_KEY_ID,
                                     aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                                     region_name="us-west-1")

bedrock_model = BedrockModel(
    model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
    temperature=0.3,
    boto_session=boto_session
)
agent = Agent(model=bedrock_model)

# Ask the agent a question
agent("Tell me about agentic AI")

To make it work, I had to update

strands/models/bedrock.py code as below

        # updated self.client as below

class BedrockModel(Model):
        ....
        ....
        self.client = boto3.client('bedrock-runtime', region_name="us-east-1")
        # self.client = session.client(
        #     service_name="bedrock-runtime",
        #     config=client_config,
        # )

Expected Behavior

It should not give me access violation as I already have access

Actual Behavior

getting error as "Your account is not authorized to invoke this API operation."

Additional Context

No response

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions