generated from geekcell/terraform-aws-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
69 lines (53 loc) · 1.89 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
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
/**
* # Terraform AWS ECS Cluster
*
* This Terraform module provides a preconfigured solution for setting up an Amazon Elastic Container Service (ECS)
* Cluster with enabled Container Insights, logging, and advanced monitoring. With this module, you can easily launch,
* manage, and scale your Docker containers and applications in the cloud while having complete visibility into their
* performance and health.
*/
resource "aws_ecs_cluster" "main" {
name = var.name
dynamic "setting" {
for_each = var.enable_container_insights ? [true] : []
content {
name = "containerInsights"
value = "enabled"
}
}
dynamic "configuration" {
for_each = var.encrypt_execute_command_session || var.logging_execute_command_session != "DEFAULT" ? [true] : []
content {
execute_command_configuration {
kms_key_id = var.encrypt_execute_command_session ? module.kms[0].key_id : null
logging = var.logging_execute_command_session
dynamic "log_configuration" {
for_each = var.logging_execute_command_session == "OVERRIDE" ? [true] : []
content {
cloud_watch_encryption_enabled = false
cloud_watch_log_group_name = aws_cloudwatch_log_group.main[0].name
}
}
}
}
}
tags = var.tags
}
module "kms" {
count = var.encrypt_execute_command_session ? 1 : 0
source = "geekcell/kms/aws"
version = ">= 1.0.0, < 2.0.0"
alias = "ecs/cluster/${var.name}/ssm-logs"
tags = var.tags
}
resource "aws_cloudwatch_log_group" "main" {
count = var.logging_execute_command_session == "OVERRIDE" ? 1 : 0
name = "/ecs/cluster/${var.name}/ssm-logs"
tags = var.tags
}
resource "aws_cloudwatch_log_group" "container_insights" {
count = var.enable_container_insights ? 1 : 0
name = "/aws/ecs/containerinsights/${var.name}/performance"
retention_in_days = 1
tags = var.tags
}