Skip to content

Commit 895d18a

Browse files
author
Bob Strahan
committed
Remove hardcoded region parameters from BDA blueprint classes
1 parent 55f166c commit 895d18a

File tree

3 files changed

+7
-37
lines changed

3 files changed

+7
-37
lines changed

lib/idp_common_pkg/idp_common/bda/bda_blueprint_creator.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313

1414
class BDABlueprintCreator:
15-
def __init__(self, region_name="us-west-2"):
15+
def __init__(self):
1616
"""Initialize Bedrock client."""
17-
self.bedrock_client = boto3.client(
18-
service_name="bedrock-data-automation", region_name=region_name
19-
)
17+
self.bedrock_client = boto3.client(service_name="bedrock-data-automation")
2018

2119
def update_data_automation_project(self, projectArn: str, blueprint):
2220
"""
@@ -209,7 +207,6 @@ def create_blueprint(self, document_type, blueprint_name, schema=None):
209207
Args:
210208
document_type (str): Type of document
211209
blueprint_name (str): Name for the blueprint
212-
region (str): AWS region
213210
labels (list, optional): List of labels for the document
214211
215212
Returns:

lib/idp_common_pkg/idp_common/bda/bda_blueprint_service.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@
1616

1717

1818
class BdaBlueprintService:
19-
def __init__(
20-
self,
21-
dataAutomationProjectArn: Optional[str] = None,
22-
region: Optional[str] = "us-west-2",
23-
):
19+
def __init__(self, dataAutomationProjectArn: Optional[str] = None):
2420
self.dataAutomationProjectArn = dataAutomationProjectArn
25-
self.region = region or os.environ.get("AWS_REGION", "us-east-1")
26-
self.blueprint_creator = BDABlueprintCreator(region_name=self.region)
21+
self.blueprint_creator = BDABlueprintCreator()
2722
self.configuration_table_name = os.environ.get("CONFIGURATION_TABLE_NAME", "")
2823
dynamodb = boto3.resource("dynamodb")
2924
self.configuration_table = dynamodb.Table(self.configuration_table_name)

lib/idp_common_pkg/tests/unit/bda/test_bda_blueprint_service.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ def service(self):
136136
mock_boto_client.return_value = mock_bedrock_client
137137

138138
service = BdaBlueprintService(
139-
dataAutomationProjectArn="arn:aws:bedrock:us-west-2:123456789012:project/test-project",
140-
region="us-west-2",
139+
dataAutomationProjectArn="arn:aws:bedrock:us-west-2:123456789012:project/test-project"
141140
)
142141

143142
# Store mocks for access in tests
@@ -164,42 +163,21 @@ def test_init(self):
164163
),
165164
):
166165
service = BdaBlueprintService(
167-
dataAutomationProjectArn="arn:aws:bedrock:us-west-2:123456789012:project/test-project",
168-
region="us-west-2",
166+
dataAutomationProjectArn="arn:aws:bedrock:us-west-2:123456789012:project/test-project"
169167
)
170168

171169
assert (
172170
service.dataAutomationProjectArn
173171
== "arn:aws:bedrock:us-west-2:123456789012:project/test-project"
174172
)
175-
assert service.region == "us-west-2"
176173
assert service.configuration_table_name == "test-config-table"
177174

178175
# Verify boto3 client was called for BDABlueprintCreator
179-
mock_boto_client.assert_called_with(
180-
service_name="bedrock-data-automation", region_name="us-west-2"
181-
)
176+
mock_boto_client.assert_called_with(service_name="bedrock-data-automation")
182177

183178
# Verify DynamoDB table was set up
184179
mock_dynamodb.assert_called_once_with("dynamodb")
185180

186-
def test_init_with_default_region(self):
187-
"""Test initialization with default region from environment."""
188-
with (
189-
patch("boto3.resource"),
190-
patch("boto3.client"),
191-
patch.dict(
192-
"os.environ",
193-
{"AWS_REGION": "us-east-1", "CONFIGURATION_TABLE_NAME": "test-table"},
194-
),
195-
):
196-
service = BdaBlueprintService(
197-
dataAutomationProjectArn="arn:aws:bedrock:us-west-2:123456789012:project/test-project",
198-
region=None, # Explicitly pass None to trigger environment lookup
199-
)
200-
201-
assert service.region == "us-east-1"
202-
203181
def test_stringify_values(self, service):
204182
"""Test the _stringify_values method."""
205183
# Test with mixed data types

0 commit comments

Comments
 (0)