Web task definition

Web task definition uses EC2 launch type. The docker iamge which web uses is provided. Leave default unless specified.

Create web task definition

  1. Move to Amazon ECS Task definition. Click Create new Task Definition
  2. Select launch type compatibility: EC2 SelectEC2
  3. Task Definition Name: web
  • Leave default Task Role and Network Mode etc, unless specified. WebTask

Amazon ECS support GUI (AWS Management console) and CLI (AWS Copilot, aws cli, ecscli). AWS Management console provides two ways to create task definition, 1) configure via JSON templete and 2) step-by-step configuration via AWS console. You may try JSON template configuration to create web task def.

1) Configure via JSON Template

  1. Scroll down to Configure via JSON.
  2. Copy and paste below JSON file.
{
    "requiresCompatibilities": [
        "EC2"
    ],
    "inferenceAccelerators": [],
    "containerDefinitions": [
      {
        "dnsSearchDomains": null,
        "environmentFiles": null,
        "logConfiguration": null,
        "entryPoint": null,
        "portMappings": [
          {
            "hostPort": 0,
            "protocol": "tcp",
            "containerPort": 80
          }
        ],
        "command": null,
        "linuxParameters": null,
        "cpu": 0,
        "environment": [],
        "resourceRequirements": null,
        "ulimits": null,
        "dnsServers": null,
        "mountPoints": [],
        "workingDirectory": null,
        "secrets": null,
        "dockerSecurityOptions": null,
        "memory": 128,
        "memoryReservation": null,
        "volumesFrom": [],
        "stopTimeout": null,
        "image": "038445823716.dkr.ecr.ap-northeast-2.amazonaws.com/web:latest",
        "startTimeout": null,
        "firelensConfiguration": null,
        "dependsOn": null,
        "disableNetworking": null,
        "interactive": null,
        "healthCheck": null,
        "essential": true,
        "links": null,
        "hostname": null,
        "extraHosts": null,
        "pseudoTerminal": null,
        "user": null,
        "readonlyRootFilesystem": null,
        "dockerLabels": null,
        "systemControls": null,
        "privileged": null,
        "name": "web"
      }],
    "volumes": [],
    "networkMode": null,
    "memory": null,
    "cpu": null,
    "placementConstraints": [],
    "tags": [],
    "family": "web"
}
  1. Click Create.

2) Step-by-step Configuraton via AWS Management Console

If you created web task def using JSON, please skip this part. You may compare what are the differencets when you configure GUI just for reference.

  1. Scroll down to Container Definitions and click Add container. AddWebContainer
  2. Config web container.
    ConfigWebContainer
  • Container name: web
  • Image: 038445823716.dkr.ecr.ap-northeast-2.amazonaws.com/web:latest
  • Memory Limits - Hard limit 128
  • Port mappings
    • Host port: 0
    • Container port: 80
  1. Click Add in tne bottom right. The window closes.
  2. Click create.