generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
43 lines (34 loc) · 1.19 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
data "aws_iam_policy_document" "assume" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${var.observability_platform_account_id}:root"]
}
}
}
resource "aws_iam_role" "this" {
name = var.role_name
path = "/"
assume_role_policy = data.aws_iam_policy_document.assume.json
tags = var.tags
}
resource "aws_iam_role_policy_attachment" "cloudwatch_readonly_access" {
role = aws_iam_role.this.name
policy_arn = "arn:aws:iam::aws:policy/CloudWatchReadOnlyAccess"
}
resource "aws_iam_role_policy_attachment" "amazon_prometheus_query_access" {
count = var.enable_prometheus ? 1 : 0
role = aws_iam_role.this.name
policy_arn = "arn:aws:iam::aws:policy/AmazonPrometheusQueryAccess"
}
resource "aws_iam_role_policy_attachment" "xray_readonly_access" {
count = var.enable_xray ? 1 : 0
role = aws_iam_role.this.name
policy_arn = "arn:aws:iam::aws:policy/AWSXrayReadOnlyAccess"
}
resource "aws_iam_role_policy_attachment" "additional_policies" {
for_each = { for k, v in var.additional_policies : k => v }
role = aws_iam_role.this.name
policy_arn = each.value
}