-
Notifications
You must be signed in to change notification settings - Fork 2
/
grafana.tf
65 lines (54 loc) · 1.24 KB
/
grafana.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
resource "aws_iam_user" "grafana" { #trivy:ignore:AVD-AWS-0143
name = "grafana"
}
data "aws_iam_policy_document" "grafana-cloudwatch" {
statement {
sid = "readMetrics"
actions = [
"cloudwatch:DescribeAlarmsForMetric",
"cloudwatch:DescribeAlarmHistory",
"cloudwatch:DescribeAlarms",
"cloudwatch:ListMetrics",
"cloudwatch:GetMetricData",
"cloudwatch:GetInsightRuleReport",
]
resources = [
"*",
]
}
statement {
sid = "readLogs"
actions = [
"logs:DescribeLogGroups",
"logs:GetLogGroupFields",
"logs:StartQuery",
"logs:StopQuery",
"logs:GetQueryResults",
"logs:GetLogEvents",
]
resources = [
"*",
]
}
statement {
sid = "readTags"
actions = [
"ec2:DescribeTags",
"ec2:DescribeInstances",
"ec2:DescribeRegions",
"tag:GetResources",
]
resources = [
"*",
]
}
}
resource "aws_iam_user_policy" "grafana-cloudwatch" {
name = "grafana-cloudwatch"
user = aws_iam_user.grafana.name
policy = data.aws_iam_policy_document.grafana-cloudwatch.json
}
resource "awscreds_iam_access_key" "grafana" {
user = aws_iam_user.grafana.name
file = "creds/${aws_iam_user.grafana.name}"
}