Description
Fargate requires awsvpc. On EC2, use awsvpc for a dedicated interface and security groups per task, or keep none for Linux tasks that need no external connectivity.
Potential impact
The wrong mode can prevent required connections or make it harder to restrict access to individual tasks.
Remediation
Set NetworkMode: awsvpc, then specify subnets and security groups when creating the service or running the task. Verify that the rules allow the required traffic.
Examples
The example changes none to awsvpc for a task that needs a network connection. Supply the task sizing and launch-time network settings separately.
Before
yaml
Resources:
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
NetworkMode: none
ContainerDefinitions:
- Name: app
Image: amazon/amazon-ecs-sample
After
yaml
Resources:
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
NetworkMode: awsvpc
ContainerDefinitions:
- Name: app
Image: amazon/amazon-ecs-sample