-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
35 lines (32 loc) · 1.18 KB
/
main.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
locals {
managed_by = "Terraform"
}
resource "aws_ecs_cluster" "ecs_cluster" {
name = var.cluster_name
tags = {
"Name" = var.cluster_name
"ManagedBy" = local.managed_by
"Environment" = var.environment
}
}
resource "aws_ecs_capacity_provider" "capacity_providers" {
for_each = { for name, capacity_provider in var.capacity_providers : capacity_provider.name => capacity_provider }
name = "${var.environment}_${each.value.name}"
auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.ecs_cluster_asg[each.key].arn
managed_scaling {
target_capacity = each.value.target_capacity
status = each.value.managed_scaling_status
}
managed_termination_protection = each.value.managed_termination_protection
}
tags = {
"ManagedBy" = local.managed_by
}
depends_on = [aws_autoscaling_group.ecs_cluster_asg]
}
resource "aws_ecs_cluster_capacity_providers" "ecs_cluster_capacity_provider" {
cluster_name = aws_ecs_cluster.ecs_cluster.name
capacity_providers = [for cp in aws_ecs_capacity_provider.capacity_providers : cp.name]
depends_on = [aws_ecs_capacity_provider.capacity_providers]
}