-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
61 lines (51 loc) · 1.49 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
data "aws_iam_policy_document" "drata_autopilot_assume_role" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = [var.drata_aws_account_arn]
}
dynamic "condition" {
for_each = var.role_sts_externalid != null ? [true] : []
content {
test = "StringEquals"
variable = "sts:ExternalId"
values = [var.role_sts_externalid]
}
}
}
}
resource "aws_iam_policy" "drata_additional_permissions" {
name = "DrataAdditionalPermissions"
description = "Custom policy for permissions in addition to the SecurityAudit policy"
path = "/"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"backup:ListBackupJobs",
"backup:ListRecoveryPointsByResource"
]
Resource = "*"
}
]
})
}
resource "aws_iam_role" "drata" {
name = var.role_name
path = var.role_path
description = var.role_description
assume_role_policy = data.aws_iam_policy_document.drata_autopilot_assume_role.json
tags = var.tags
}
resource "aws_iam_role_policy_attachment" "security_audit" {
role = aws_iam_role.drata.name
policy_arn = "arn:aws:iam::aws:policy/SecurityAudit"
}
resource "aws_iam_role_policy_attachment" "drata_additional_permissions" {
role = aws_iam_role.drata.name
policy_arn = aws_iam_policy.drata_additional_permissions.arn
}