Terraform:无法启动 ECS Fargate launchType
Terraform: Unable to launch ECS Fargate launchType
我正在尝试使用 Fargate 任务启动 ECS 集群。
这是我的 Terraform 资源
resource "aws_ecs_task_definition" "ecs-zoo" {
family = "${var.project}"
container_definitions = "${data.template_file.ecs-zookeeper.rendered}"
network_mode = "awsvpc"
cpu = 512
memory = 1024
requires_compatibilities = ["FARGATE"]
}
这是我的任务定义
[
{
"name": "zoo",
"image": "${zoo_image}",
"essential": true,
"portMappings": [
{
"containerPort": ${zook_port},
"hostPort": ${zook_port}
}
],
"environment": [
{
"name": "ZOO_SERVERS",
"value": "${zook-servers}"
}
]
}
]
这里是服务资源
resource "aws_ecs_service" "ecs-zoo" {
name = "${var.project}${count.index+1}"
cluster = "${aws_ecs_cluster.ecs.id}"
task_definition = "${aws_ecs_task_definition.ecs-zoo.arn}"
enable_ecs_managed_tags = true
desired_count = 1
propagate_tags = "SERVICE"
deployment_minimum_healthy_percent = 100
deployment_maximum_percent = 400
network_configuration {
subnets = "${var.vpc_subnets}"
security_groups = ["${aws_security_group.ecs.id}"]
assign_public_ip = false
}
service_registries {
registry_arn = "${aws_service_discovery_service.discovery_service-zoo.*.arn[count.index]}"
}
lifecycle {
create_before_destroy = true
}
count = "${var.zoo-instance-number}"
}
问题是它只启动 EC2 任务,而不启动 FARGATE,正如您在快照中看到的那样。
如果我检查控制台中的任务定义,它是这样说的
我做错了什么?
您需要在服务定义中指定launch_type = "FARGATE"
。
我正在尝试使用 Fargate 任务启动 ECS 集群。
这是我的 Terraform 资源
resource "aws_ecs_task_definition" "ecs-zoo" {
family = "${var.project}"
container_definitions = "${data.template_file.ecs-zookeeper.rendered}"
network_mode = "awsvpc"
cpu = 512
memory = 1024
requires_compatibilities = ["FARGATE"]
}
这是我的任务定义
[
{
"name": "zoo",
"image": "${zoo_image}",
"essential": true,
"portMappings": [
{
"containerPort": ${zook_port},
"hostPort": ${zook_port}
}
],
"environment": [
{
"name": "ZOO_SERVERS",
"value": "${zook-servers}"
}
]
}
]
这里是服务资源
resource "aws_ecs_service" "ecs-zoo" {
name = "${var.project}${count.index+1}"
cluster = "${aws_ecs_cluster.ecs.id}"
task_definition = "${aws_ecs_task_definition.ecs-zoo.arn}"
enable_ecs_managed_tags = true
desired_count = 1
propagate_tags = "SERVICE"
deployment_minimum_healthy_percent = 100
deployment_maximum_percent = 400
network_configuration {
subnets = "${var.vpc_subnets}"
security_groups = ["${aws_security_group.ecs.id}"]
assign_public_ip = false
}
service_registries {
registry_arn = "${aws_service_discovery_service.discovery_service-zoo.*.arn[count.index]}"
}
lifecycle {
create_before_destroy = true
}
count = "${var.zoo-instance-number}"
}
问题是它只启动 EC2 任务,而不启动 FARGATE,正如您在快照中看到的那样。
如果我检查控制台中的任务定义,它是这样说的
我做错了什么?
您需要在服务定义中指定launch_type = "FARGATE"
。