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
}
}
bridge
network with Fargate;awsvpc
only. – bluescores