我正在使用Terraform设置新的ECS集群。 创建群集本身时,如何使用terraform启动ecs群集实例。 谁能使用terraform资源帮助我编写脚本
resource "aws_ecs_cluster" "core-ecs-cluster" {
name = "${var.ecs_cluster}"
#launch_type = "EC2"
}
resource "aws_ecs_task_definition" "app" {
family = "app"
container_definitions = "${file("ecs/service.json")}"
requires_compatibilities = ["EC2"]
volume {
name = "service-storage"
host_path = "/ecs/service-storage"
}
placement_constraints {
type = "memberOf"
expression = "attribute:ecs.availability-zone in [ap-south-1a, ap-south-1b]"
}
}
resource "aws_ecs_service" "mds" {
name = "mds"
cluster = "${aws_ecs_cluster.core-ecs-cluster.id}"
task_definition = "${aws_ecs_task_definition.task-def-service.family}:${max("${aws_ecs_task_definition.task-def-service.revision}")}"
desired_count = 1
#iam_role = "${aws_iam_role.ecs-service-role-1.arn}"
#depends_on = ["aws_iam_role_policy.ecs-service-role"]
launch_type = "EC2"
ordered_placement_strategy {
type = "binpack"
field = "cpu"
}
load_balancer {
target_group_arn = "${aws_alb_target_group.ecs-target-group.arn}"
container_name = "core-v2-test"
container_port = 3000
}
placement_constraints {
type = "memberOf"
expression = "attribute:ecs.availability-zone in [ap-south-1a, ap-south-1b]"
}
}