[我是Terraform和ECS的新手,我正在使用this example创建ECS EC2类型的集群,该集群将自动扩展并使用应用程序负载均衡器。
我的问题是:main.tf
中的代码段如何?>
resource "aws_ecs_service" "test" { name = "tf-example-ecs-ghost" cluster = "${aws_ecs_cluster.main.id}" task_definition = "${aws_ecs_task_definition.ghost.arn}" desired_count = "${var.service_desired}" iam_role = "${aws_iam_role.ecs_service.name}" load_balancer { target_group_arn = "${aws_alb_target_group.test.id}" container_name = "ghost" container_port = "2368" } depends_on = [ "aws_iam_role_policy.ecs_service", "aws_alb_listener.front_end", ] }
已连接到资源
aws_autoscaling_group.app
:
resource "aws_autoscaling_group" "app" { name = "tf-test-asg" vpc_zone_identifier = ["${aws_subnet.main.*.id}"] min_size = "${var.asg_min}" max_size = "${var.asg_max}" desired_capacity = "${var.asg_desired}" launch_configuration = "${aws_launch_configuration.app.name}" }
由于
aws_ecs_service
资源定义中没有指向aws_autoscaling_group
资源的插值变量,因此ECS服务定义如何知道在哪里找到此自动缩放组?它引用目标组,但目标组未引用自动伸缩组。这就是为什么我很困惑,因为在资源“ ecs-service”和资源“ aws-autoscaling”之间没有明显的引用。还是代码缺少smth?请尽可能提供详尽的说明。
我是Terraform和ECS的新手,并且我使用此示例创建ECS EC2类型的集群,该集群将自动扩展并使用应用程序负载均衡器。我的问题是:main ....
不是。