Open jasonpatt opened 4 years ago
Hey Jason, sorry for the delay on this. When specifying the container for the ECS service, can you not just do { portMappings: [{ hostPort: 0 }] }
?
@CyrusNajmabadi I am facing a similar issue Doing the above creates a service without a Loadbalancer Is there any way to do this ?
This is my workaround:
class WindowsEC2DynamicPortApplicationListener extends awsx.elasticloadbalancingv2.ApplicationListener{
constructor(name: string, args: awsx.elasticloadbalancingv2.ApplicationListenerArgs, opts?: pulumi.ComponentResourceOptions) {
super(name, args, opts);
}
public containerPortMapping(name: string, parent: pulumi.Resource) {
const portMapping = super.containerPortMapping(name, parent);
const withHostPort = pulumi.output(portMapping).apply(pm => {
return ({...pm, hostPort: 0});
});
return withHostPort;
}
}
I am attempting to create a Windows ECS service with dynamic port mapping of the container instances. The AWS documentation states that the hostPort in the container definition needs to be set to 0. (https://aws.amazon.com/premiumsupport/knowledge-center/dynamic-port-mapping-ecs/) However, pulumi always sets the hostPort equal to the containerPort. This will never work with dyanamic port mapping of Windows container instances.
I have found the line of code that is causing the problems, in container.ts:
If I delete the line, copy.hostPort = copy.containerPort, then everything works.
My question, what is the best approach to support this use case?
I am happy to create a pull request to support this, I just need some guidance on the best strategy.
Any thoughts?
Thanks,