-
Notifications
You must be signed in to change notification settings - Fork 0
/
cw_dashboard.tf
109 lines (108 loc) · 3.22 KB
/
cw_dashboard.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
locals {
dashboard_query = <<-EOT
SOURCE '/aws/lambda/${var.lambda_function_name}'
| fields @timestamp, @message
| filter @message not like 'START RequestId'
| filter @message not like 'REPORT RequestId'
| filter @message not like 'END RequestId'
| filter @message not like 'INIT_START'
| sort @timestamp desc
| limit 100
EOT
dashboard_widget_regions = [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ap-northeast-1",
"ap-southeast-1",
]
}
resource "aws_cloudwatch_dashboard" "dashboard" {
count = terraform.workspace == "default" && var.enable_cloudwatch_dashboard ? 1 : 0
dashboard_name = "AWSAutoTaggingDashboard"
dashboard_body = jsonencode(
{
"widgets" : [
{
"type" : "log",
"x" : 0,
"y" : 0,
"width" : 12,
"height" : 6,
"properties" : {
"region" : "${local.dashboard_widget_regions[0]}",
"title" : "/aws/lambda/${var.lambda_function_name} (${local.dashboard_widget_regions[0]})",
"query" : "${local.dashboard_query}",
"view" : "table"
}
},
{
"type" : "log",
"x" : 12,
"y" : 0,
"width" : 12,
"height" : 6,
"properties" : {
"region" : "${local.dashboard_widget_regions[1]}",
"title" : "/aws/lambda/${var.lambda_function_name} (${local.dashboard_widget_regions[1]})",
"query" : "${local.dashboard_query}",
"view" : "table"
}
},
{
"type" : "log",
"x" : 0,
"y" : 6,
"width" : 12,
"height" : 6,
"properties" : {
"region" : "${local.dashboard_widget_regions[2]}",
"title" : "/aws/lambda/${var.lambda_function_name} (${local.dashboard_widget_regions[2]})",
"query" : "${local.dashboard_query}",
"view" : "table"
}
},
{
"type" : "log",
"x" : 12,
"y" : 6,
"width" : 12,
"height" : 6,
"properties" : {
"region" : "${local.dashboard_widget_regions[3]}",
"title" : "/aws/lambda/${var.lambda_function_name} (${local.dashboard_widget_regions[3]})",
"query" : "${local.dashboard_query}",
"view" : "table"
}
},
{
"type" : "log",
"x" : 0,
"y" : 12,
"width" : 12,
"height" : 6,
"properties" : {
"region" : "${local.dashboard_widget_regions[4]}",
"title" : "/aws/lambda/${var.lambda_function_name} (${local.dashboard_widget_regions[4]})",
"query" : "${local.dashboard_query}",
"view" : "table"
}
},
{
"type" : "log",
"x" : 12,
"y" : 12,
"width" : 12,
"height" : 6,
"properties" : {
"region" : "${local.dashboard_widget_regions[5]}",
"title" : "/aws/lambda/${var.lambda_function_name} (${local.dashboard_widget_regions[5]})",
"query" : "${local.dashboard_query}",
"view" : "table"
}
},
]
}
)
}