-
Notifications
You must be signed in to change notification settings - Fork 6
/
cloudwatch_dashbaord.tf
38 lines (34 loc) · 1.32 KB
/
cloudwatch_dashbaord.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
/*
Module: ECS-Fargate-Appmesh
Version: 1.0.0
This file will create following:
- cloudwatch dashboard for app and virtual gateway
*/
data "template_file" "lb_dash_body" {
template = file("${path.module}/templates/lb_dash_body.json.tpl")
vars = {
service_name = aws_ecs_service.main.name
cluster_name = aws_ecs_cluster.main.name
loggroupname = aws_cloudwatch_log_group.fargate_service_log_group.name
region = var.region
az_first = "${var.region}a"
az_second = "${var.region}b"
loadbalancer = var.virtual_gateway_arn == "none" ? "none" : "net/${aws_lb.main[0].name}/${split("/", aws_lb.main[0].arn)[3]}"
}
}
data "template_file" "gen_dash_body" {
template = file("${path.module}/templates/dash_body.json.tpl")
vars = {
service_name = aws_ecs_service.main.name
cluster_name = aws_ecs_cluster.main.name
loggroupname = aws_cloudwatch_log_group.fargate_service_log_group.name
region = var.region
az_first = "${var.region}a"
az_second = "${var.region}b"
}
}
resource "aws_cloudwatch_dashboard" "gen_dashboard" {
count = var.cw_dashboard == "none" ? 0 : 1
dashboard_name = "${var.env}-${var.app_name}-dashboard"
dashboard_body = var.virtual_gateway_arn == "none" ? data.template_file.gen_dash_body.rendered : data.template_file.lb_dash_body.rendered
}