Description
For Fargate, assign_public_ip: true requests a public IPv4 address for each task. Direct connections also need an internet gateway route and a security group that allows the traffic. The application still controls authentication.
Potential impact
Traffic that reaches a task directly can avoid access controls on its load balancer.
Remediation
For private tasks, set assign_public_ip: false and use private subnets. First provide NAT or supported VPC endpoints for image pulls, logging and external calls. Limit traffic from the load balancer and test the deployed tasks’ actual connectivity, including IPv6.
Examples
Supply the cluster, awsvpc task definition, subnets and security groups.
Before
- name: ECS 서비스 생성
community.aws.ecs_service:
state: present
name: example-public-ip-service
cluster: my-ecs-cluster
task_definition: my-task-def:1
desired_count: 2
launch_type: FARGATE
network_configuration:
subnets:
- subnet-aaaa1111
- subnet-bbbb2222
security_groups:
- sg-cccc3333
assign_public_ip: true
After
- name: ECS 서비스 생성
community.aws.ecs_service:
state: present
name: example-private-service
cluster: my-ecs-cluster
task_definition: my-task-def:1
desired_count: 2
launch_type: FARGATE
network_configuration:
subnets:
- subnet-aaaa1111
- subnet-bbbb2222
security_groups:
- sg-cccc3333
assign_public_ip: false
example-private-service is a different service. To remove the public path to example-public-ip-service, update or retire that service separately.