-
Notifications
You must be signed in to change notification settings - Fork 4
/
iam_xacnt_role.tf
110 lines (90 loc) · 2.25 KB
/
iam_xacnt_role.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
110
resource "aws_iam_role" "maskopy_source_account_role" {
provider = aws.source
count = var.enabled ? 1 : 0
name = "XACNT_MASKOPY"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "ec2.amazonaws.com"
}
},
{
"Sid" : "",
"Effect" : "Allow",
"Principal" : {
"AWS" : "arn:aws:iam::${data.aws_caller_identity.staging.account_id}:role/${var.lambda_role_name}"
},
"Action" : "sts:AssumeRole"
}
]
})
tags = {
Tool = "MASKOPY"
}
}
resource "aws_iam_policy" "xacnt_maskopy_policy" {
provider = aws.source
count = var.enabled ? 1 : 0
name = "xacnt-maskopy-policy"
description = "XACNT maskopy policy"
policy = data.aws_iam_policy_document.xacnt_maskopy_policy_doc.json
}
resource "aws_iam_role_policy_attachment" "maskopy_source_account_policy_attachment" {
provider = aws.source
count = var.enabled ? 1 : 0
role = aws_iam_role.maskopy_source_account_role[0].name
policy_arn = aws_iam_policy.xacnt_maskopy_policy[0].arn
}
data "aws_iam_policy_document" "xacnt_maskopy_policy_doc" {
statement {
sid = "KMSandLogs"
effect = "Allow"
actions = [
"logs:CreateLogStream",
"kms:List*",
"kms:Get*",
"kms:CreateAlias",
"kms:Describe*",
"kms:CreateKey",
"kms:CreateGrant",
"logs:CreateLogGroup",
"logs:PutLogEvents",
"kms:ReEncrypt*",
"kms:GenerateDataKey",
"kms:Decrypt"
]
resources = [
"*"
]
}
statement {
sid = "RDSSnapshotPolicy"
effect = "Allow"
actions = [
"rds:ListTagsForResource",
"rds:DescribeDBSnapshots",
"rds:CopyDBSnapshot",
"rds:ModifyDBSnapshotAttribute",
"rds:DescribeDBInstances",
"rds:AddTagsToResource"
]
resources = [
"arn:aws:rds:*:${data.aws_caller_identity.source.account_id}:*:*"
]
}
statement {
sid = "RDSDeletePolicy"
effect = "Allow"
actions = [
"rds:DeleteDBSnapshot"
]
resources = [
"arn:aws:rds:*:${data.aws_caller_identity.source.account_id}:*:maskopy*"
]
}
}