-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecs.tf
73 lines (61 loc) · 1.91 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
65
66
67
68
69
70
71
72
73
module "ecs_cluster" {
source = "./modules/ecs-cluster"
name = local.namespace
vpc_id = module.vpc.vpc_id
ecs_subnets = [module.subnets.private_subnet_ids[1]]
security_groups = [aws_security_group.ecs.id]
default_instance_type = "t3a.medium"
instance_types = {
"t3a.medium" = 1
}
min_size = 2
max_size = 4
minimum_scaling_step_size = 1
maximum_scaling_step_size = 1
target_capacity = 100
capacity_rebalance = false
on_demand_base_capacity = 0
on_demand_percentage_above_base_capacity = 100
ecs_cloudwatch_log_retention = 30
userdata_cloudwatch_log_retention = 30
spot_allocation_strategy = "price-capacity-optimized"
spot_instance_pools = 0
service_discovery_domain = "${local.namespace}.svc"
depends_on = [aws_iam_service_linked_role.ecs]
}
resource "aws_iam_service_linked_role" "ecs" {
count = var.create_iam_service_linked_role ? 1 : 0
aws_service_name = "ecs.amazonaws.com"
}
resource "aws_security_group" "ecs" {
name = "${local.namespace}-ecs"
description = "Inbound - Security Group attached to the ECS Service (${var.environment})"
vpc_id = module.vpc.vpc_id
ingress {
description = "Load balancer traffic"
from_port = 80
to_port = 80
protocol = "tcp"
security_groups = [aws_security_group.lb.id]
}
ingress {
description = "Internal traffic"
from_port = 0
to_port = 0
protocol = "-1"
self = true
}
ingress {
description = "Bastion access"
from_port = 0
to_port = 0
protocol = "-1"
security_groups = [aws_security_group.bastion.id]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}