forked from 7Factor/terraform-ecs-http-task
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecs.tf
30 lines (26 loc) · 1014 Bytes
/
ecs.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
data "aws_ecs_cluster" "target_cluster" {
cluster_name = "${var.cluster_name}"
}
resource "aws_ecs_task_definition" "main_task" {
family = "${var.app_name}-tsk"
requires_compatibilities = ["EC2"]
network_mode = "bridge"
cpu = "${var.cpu}"
memory = "${var.memory}"
container_definitions = "${var.container_definition}"
task_role_arn = "${var.task_role_arn}"
}
resource "aws_ecs_service" "main_service" {
name = "${var.app_name}-svc"
task_definition = "${aws_ecs_task_definition.main_task.arn}"
cluster = "${data.aws_ecs_cluster.target_cluster.id}"
desired_count = "${var.desired_task_count}"
iam_role = "${var.service_role_arn}"
launch_type = "${var.launch_type}"
load_balancer {
container_name = "${var.app_name}-cnt"
container_port = "${var.app_port}"
target_group_arn = "${aws_lb_target_group.lb_targets.arn}"
}
depends_on = [aws_lb.app_lb]
}