This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
iam.tf
120 lines (117 loc) · 2.8 KB
/
iam.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
111
112
113
114
115
116
117
118
119
120
data "aws_iam_policy_document" "assume_lambda_role" {
statement {
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
actions = ["sts:AssumeRole"]
}
}
resource "aws_iam_role" "restore_object_role" {
name = "${var.prefix}_restore_object_role"
assume_role_policy = data.aws_iam_policy_document.assume_lambda_role.json
permissions_boundary = var.permissions_boundary_arn
}
data "aws_iam_policy_document" "restore_object_role_policy_document" {
statement {
actions = ["sts:AssumeRole"]
resources = ["*"]
}
statement {
actions = [
"ec2:CreateNetworkInterface",
"ec2:DescribeNetworkInterfaces",
"ec2:DeleteNetworkInterface"
]
resources = ["*"]
}
statement {
actions = [
"states:SendTaskFailure",
"states:SendTaskSuccess",
"states:GetActivityTask",
"states:GetExecutionHistory",
"states:DescribeActivity",
"states:DescribeExecution",
"states:ListStateMachines"
]
resources = ["arn:aws:states:*:*:*"]
}
statement {
actions = [
"sns:publish",
"sns:List*"
]
resources = ["*"]
}
statement {
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogStreams",
"logs:PutLogEvents"
]
resources = ["*"]
}
statement {
actions = [
"s3:GetBucket",
"s3:ListBucket",
"s3:PutBucket"
]
resources = [
"arn:aws:s3:::${var.glacier_bucket}",
"arn:aws:s3:::${var.public_bucket}",
"arn:aws:s3:::${var.private_bucket}",
"arn:aws:s3:::${var.internal_bucket}",
"arn:aws:s3:::${var.protected_bucket}"
]
}
statement {
actions = [
"s3:AbortMultipartUpload",
"s3:GetObject*",
"s3:PutObject*",
"s3:ListMultipartUploadParts",
"s3:DeleteObject",
"s3:DeleteObjectVersion"
]
resources = [
"arn:aws:s3:::${var.glacier_bucket}/*",
"arn:aws:s3:::${var.public_bucket}/*",
"arn:aws:s3:::${var.private_bucket}/*",
"arn:aws:s3:::${var.internal_bucket}/*",
"arn:aws:s3:::${var.protected_bucket}/*"
]
}
statement {
actions = [
"s3:RestoreObject",
"s3:GetObject"
]
resources = [
"arn:aws:s3:::${var.glacier_bucket}",
"arn:aws:s3:::${var.glacier_bucket}/*"
]
}
statement {
actions = [
"ssm:GetParameter",
"ssm:GetParameters"
]
resources = ["*"]
}
statement {
actions = [
"kms:Decrypt"
]
resources = [
"arn:aws:kms:::key/CMK"
]
}
}
resource "aws_iam_role_policy" "restore_object_role_policy" {
name = "${var.prefix}_restore_object_role_policy"
role = aws_iam_role.restore_object_role.id
policy = data.aws_iam_policy_document.restore_object_role_policy_document.json
}