aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.66k stars 3.92k forks source link

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

Open jolo-dev opened 11 months ago

jolo-dev commented 11 months ago

Describe the feature

When using for example ApplicationLoadBalancedFargateService you can pass in taskImageOptions. However, the containerPort is from type number but should be a PortMapping[] 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

CDK version used

2.110.0

Environment details (OS name and version, etc.)

MacOS 14.1

khushail commented 11 months ago

Thanks @jolo-dev for the inputs and pull request.

paulosergio-jnr commented 10 months ago

Wouldn't this occur in a breaking change as we will have a parameter type changed?

Could we instead add another property as @jolo-dev mentioned, containerPorts: PortMapping[], and evaluating which will be passed to Cfn on building time? (both fields provided = error)

Another alternative would be marking the current containerPort as Deprecated and create the new field as mentioned.

WDYT?

jolo-dev commented 9 months ago

Hey @paulosergio-jnr, Yeah you're right. It would be a breaking change. I think making it Deprecated and creating a new field would be the cleaner approach.