0
votes

I ran Terraform plan on a Terraform script to enable Fargate but I get the following error:

Error: aws_ecs_task_definition.task: : invalid or unknown key: requires_compatibilities

and

Error: aws_ecs_service.service: : invalid or unknown key: launch_type

Not sure why Terraform is not accepting the keys launch_type and requires_compatibilities for enabling Fargate.

Below is my task and ECS service setup for Terraform:

Terraform

resource "aws_ecs_task_definition" "task" {
  family                   = "${var.name_prefix}_gateway"
  container_definitions    = "${template_file.task.rendered}"
  requires_compatibilities = ["FARGATE"]
  network_mode             = "bridge"

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_ecs_service" "service" {
  name                               = "${var.name_prefix}_service"
  launch_type                        = "FARGATE"
  cluster                            = "${aws_ecs_cluster.terraform_cluster.id}"
  task_definition                    = "${aws_ecs_task_definition.task.arn}"
  desired_count                      = "${var.desired_count}"
  deployment_minimum_healthy_percent = 50
  deployment_maximum_percent         = 200
  iam_role                           = "${var.ecs_service_role}"

  load_balancer {
    target_group_arn = "${aws_alb_target_group.svc.arn}"
    container_name   = "task"
    container_port   = 8000
  }

  lifecycle {
    create_before_destroy = true
  }
}
1
What version of Terraform and the AWS provider are you using?ydaetskcoR
Terraform v0.11.7 + provider.aws v0.1.4 + provider.template v0.1.1governingcloud
Not the answer to your question, yet relevant, you can't use a bridge network with Fargate; awsvpc only.bluescores

1 Answers

1
votes

requires_compatibilities and launch_type were introduced in v1.6.0 of the AWS provider.

Update your provider to 1.6.0 or higher and you should be fine.

Note that v0.1.4 came out in August 2017, followed by the v1.0.0 release on September 27, 2017 which was long before the Fargate announcement.