Tasks with public IP on EC2 backed ECS

0

I want to run ECS tasks on EC2 backed ECS with public IP. My tasks generates a lot of outgoing traffic and I do not want to pay for NAT.

It turned out that it is absolutely possible using Fargate backed ECS and not with EC backed.

When I create following task definition

const taskDefinition = new ecs.Ec2TaskDefinition(this, `${this.appPrefix}-task-definition`, {
   networkMode: ecs.NetworkMode.AWS_VPC,
});

and set assignPublicIp: true for my service I receive an error during deployment:

Assign public IP is not supported for this launch type.

So my question is it possible to run ECS tasks with public IP on EC2 backed cluster?

profile picture
Smotrov
질문됨 3달 전233회 조회
1개 답변
0

Hello.

If the network type is "awsvpc" for EC2 launch type ECS, you cannot set a public IP address.
So, if you need a public IP, I think you need to set the network mode to host mode or bridge mode.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-networking-awsvpc.html

When hosting tasks that use the awsvpc network mode on Amazon EC2 Linux instances, your task ENIs aren't given public IP addresses. To access the internet, tasks must be launched in a private subnet that's configured to use a NAT gateway. For more information, see NAT gateways in the Amazon VPC User Guide. Inbound network access must be from within a VPC that uses the private IP address or routed through a load balancer from within the VPC. Tasks that are launched within public subnets do not have access to the internet.

profile picture
전문가
답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠