aws / aws/aws-cdk

aws-ecs-pattern: `containerPort` should be `PortMapping[]` instead of just `number`

Open
#28,202 3 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-ecs-patterns effort/small feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

When using for example [`ApplicationLoadBalancedFargateService`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs_patterns.ApplicationLoadBalancedFargateService.html) you can pass in [`taskImageOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs_patterns.ApplicationLoadBalancedTaskImageOptions.html).
However, the `containerPort` is from type `number ` but should be a [`PortMapping[]`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.PortMapping.html) instead.
I ran into the issue that I needed that because my container exposed multiple Ports thus I had to create a `taskDefinition` due to that.

### Use Case

Container, which exposes multiple ports. This is possible through `taskDefinition` but would bloat the codebase.

### Proposed Solution

Instead of `containerPort: number`, it should be `containerPorts: PortMapping[]`.

### 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.110.0

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

MacOS 14.1

Contributor guide

Open the contributing guide

Research direction

Start with ApplicationLoadBalancedFargateService and its taskImageOptions, then trace how containerPort is defined and passed into the ECS task definition. Compare the current number-based API with the PortMapping[] type and verify that multiple exposed ports are supported without requiring a separately created taskDefinition.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.