Skip to content

Commit d7987c0

Browse files
authored
Fix Hardcoded Region in Task Definition Log Group (#259)
Fix hardcoded region in task definition log group. Region was previously hardcoded to us-east-2. Region is now dynamically determined from the environment and aligned with other resources in the setup
1 parent b25dfdd commit d7987c0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/swerex/deployment/fargate.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,12 @@ async def start(
146146
self.logger.info(f"Fargate container started in {time.time() - t0:.2f}s")
147147
if self._config.log_group:
148148
try:
149+
region = ecs_client.meta.region_name
149150
log_url = get_cloudwatch_log_url(
150151
task_arn=self._task_arn,
151152
task_definition=self._task_definition,
152153
container_name=self._container_name,
154+
region=region,
153155
)
154156
self.logger.info(f"Monitor logs at: {log_url}")
155157
except Exception as e:

src/swerex/utils/aws.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ def get_task_definition(
9898
log_group: str | None = None,
9999
) -> str:
100100
ecs_client = boto3.client("ecs")
101+
region = ecs_client.meta.region_name
102+
101103
task_definition = {
102104
"executionRoleArn": execution_role_arn,
103105
"networkMode": "awsvpc",
@@ -122,7 +124,7 @@ def get_task_definition(
122124
"logDriver": "awslogs",
123125
"options": {
124126
"awslogs-group": log_group,
125-
"awslogs-region": "us-east-2",
127+
"awslogs-region": region,
126128
"awslogs-stream-prefix": "ecs",
127129
"awslogs-create-group": "true",
128130
},

0 commit comments

Comments
 (0)