-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathecs.tf
64 lines (48 loc) · 1.71 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
data "aws_ecs_cluster" "this" {
cluster_name = var.ecs_cluster_name
}
module "this_ecs_http_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "3.13.0"
name = format("%s-service-http", var.name)
vpc_id = var.vpc_id
egress_rules = ["all-all"]
computed_ingress_with_source_security_group_id = [
{
rule = "http-80-tcp"
source_security_group_id = module.this_lb_http_sg.this_security_group_id
}
]
number_of_computed_ingress_with_source_security_group_id = 1
tags = var.tags
}
resource "aws_ecs_service" "this" {
name = format("%s-%s", var.name, var.stage)
cluster = data.aws_ecs_cluster.this.arn
task_definition = var.ecs_task_definition_arn
desired_count = var.ecs_desired_count
platform_version = var.fargate_platform_version
launch_type = "FARGATE"
propagate_tags = "SERVICE"
enable_ecs_managed_tags = true
deployment_maximum_percent = var.ecs_deployment_maximum_percent
deployment_minimum_healthy_percent = var.ecs_deployment_minimum_healthy_percent
health_check_grace_period_seconds = var.ecs_health_check_grace_period_seconds
deployment_controller {
type = var.ecs_deployment_controller_type
}
load_balancer {
target_group_arn = aws_lb_target_group.http_ip.arn
container_name = var.ecs_container_name
container_port = var.ecs_container_port
}
network_configuration {
assign_public_ip = var.ecs_assign_public_ip
security_groups = [module.this_ecs_http_sg.this_security_group_id]
subnets = var.ecs_assign_public_ip ? var.public_subnet_ids : var.private_subnet_ids
}
tags = var.tags
lifecycle {
ignore_changes = [task_definition, desired_count]
}
}