aws / aws/aws-cdk

batch: support FireLens

Open
#34,270 1 comment 2 reactions 0 assignees View on GitHub
@aws-cdk/aws-batch effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

https://aws.amazon.com/about-aws/whats-new/2025/04/aws-batch-amazon-elastic-container-service-exec-firelens-log-router/

ECS Firelens now also works in Batch with ECS jobs.

### Use Case

I want to process logs from ECS batch jobs the same way I do with any other kind of ECS task.

### Proposed Solution

Add an `addFirelensLogRouter` to [EcsJobDefinition](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsJobDefinition.html) to mirror [that on TaskDefinition](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.TaskDefinition.html#addwbrfirelenswbrlogwbrrouterid-props). One problem is that EcsJobDefinition only has a unary `container` prop instead of a `containers` array. IIRC this is because batch jobs can inherently only have one container? At least until the addition of this feature: the FireLens log router is in fact another container. But because of this situation, perhaps it should not be exposed as a prop on EcsJobDefinition in the same way it is on TaskDefinition, as an element in `containers`. The [underlying L1 construct](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.CfnJobDefinition.EcsPropertiesProperty.html) of course has a `containers` array.

If the main job container uses a firelens log driver, [add a firelens log router if `addFirelensLogRouter` was not invoked](https://github.com/aws/aws-cdk/blob/7f378b6ee87a9ad89772d3cdd77c89d6a9ab8209/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts#L894-L910).

We will seemingly have to switch from `containerProperties` to `ecsProperties` in order to add a firelens log router. https://github.com/aws/aws-cdk/blob/7f378b6ee87a9ad89772d3cdd77c89d6a9ab8209/packages/aws-cdk-lib/aws-batch/lib/ecs-job-definition.ts#L97
I believe functionality achievable with the latter is a superset of the former's.

### Other Information

_No response_

### Acknowledgements

- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.192.0

### Environment details (OS name and version, etc.)

N/A

Contributor guide

Open the contributing guide

Research direction

Start with packages/aws-cdk-lib/aws-batch/lib/ecs-job-definition.ts, especially the current containerProperties handling, and compare it with packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts around addFirelensLogRouter. Determine how switching to ecsProperties can expose a FireLens router while preserving existing behavior. Done means ECS Batch jobs support an explicit router and automatically add one when the main container uses a FireLens log driver.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.