No Fargate configuration exists for given values

Getting started with Terraform and Amazon Fargate the other day and ran into this error when trying to create a new task.

No Fargate configuration exists for given values.

The issue was with my cpu and memory settings for the task. Looking at the docs these settings must match a predefined set of values. I was using 1024/1024 which is not a valid combination.

If using the Fargate launch type, this field is required and you must use one of the following values, which determines your range of supported values for the memory parameter:

  • 256 (.25 vCPU) – Available memory values: 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB)
  • 512 (.5 vCPU) – Available memory values: 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB)
  • 1024 (1 vCPU) – Available memory values: 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB)
  • 2048 (2 vCPU) – Available memory values: Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB)
  • 4096 (4 vCPU) – Available memory values: Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB)

Note that you must update the values in both the task definition and the container definition.

resource "aws_ecs_task_definition" "api" {
  family = "api"
  cpu = 512
  memory = 1024
  requires_compatibilities = ["FARGATE"]
  network_mode = "awsvpc"
  container_definitions = <<EOF
  [
    {
      "name": "api",
      "image": "myimage:latest",
      "cpu": 512,
      "memory": 1024,
      "networkMode": "awsvpc",
      "essential": true,
      "portMappings": [
        {
          "containerPort": 3000,
          "hostPort": 3000
        }
      ]
    }
  ]
  EOF
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s