[BUG] BedrockKnowledgeBaseStore throws NoRegionError in Cloud Envs
Checks
- [x] I have updated to the lastest minor and patch version of Strands
- [x] I have checked the documentation and this is not expected behavior
- [x] I have searched ./issues and there are no duplicates of my issue
SDK Language
Python
Strands Version
1.50.2
Language Runtime Version
Python 3.12
Operating System
Amazon Linux 2 (EC2)
Installation Method
pip
Steps to Reproduce
- Deploy to an EC2 instance without
AWS_DEFAULT_REGIONorAWS_REGIONenvironment variables set - Instantiate a
BedrockKnowledgeBaseStore, wrap in try-except if you want to actually catch the error:
from strands.vended_memory_stores import BedrockKnowledgeBaseStore
store = BedrockKnowledgeBaseStore(
name="user-memory",
description="Personal memories about the user",
scope="user-123",
writable=True,
config={
"knowledge_base_id": "ABCDEFGHIJ",
"data_source_type": "S3",
"data_source_id": "DATASOURCE123",
"s3": {
"bucket": "my-bucket",
"prefix": "memories/",
},
},
)
- Observe error:
NoRegionError: You must specify a region.
Expected Behavior
The BedrockKnowledgeBaseStore constructor or its config dict should accept a region or region_name parameter to specify the AWS region, similar to how BedrockModel accepts region_name, or just pick it up from the IAM role associated with the cloud resource (in this case EC2 but could be Lambda, etc.):
# This works for BedrockModel:
model = BedrockModel(model_id="anthropic.claude-3-sonnet", region_name="us-west-2")
# Expected for BedrockKnowledgeBaseStore:
store = BedrockKnowledgeBaseStore(
name="user-memory",
...,
config={
"knowledge_base_id": "ABCDEFGHIJ",
"region": "us-west-2", # or region_name
...
},
)
Additional Context
The error originates from boto3 client initialization inside the store. The BedrockModel class properly exposes region_name as a parameter, but BedrockKnowledgeBaseStore does not appear to pass region configuration to its internal boto3 clients.
Expected Behavior
Defaults to some region or another or respects IAM role region and permissions on the deployed EC2 or cloud resource.
Actual Behavior
Seems to work fine on local aws sso login and pulls those regions fine. Does not operate the same way in Cloud env.
Additional Context
No response
Possible Solution
No response
Related Issues
No response
I was able to eventually get this to work by setting this at the top level of my app:
import os
os.environ.setdefault("AWS_DEFAULT_REGION", "us-west-2")
Not ideal but it's at least a workaround.