-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
64 lines (53 loc) · 1.33 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
data "aws_iam_policy_document" "policy_document" {
statement {
actions = [
"s3:GetAccelerateConfiguration",
"s3:GetBucketLocation",
"s3:GetBucketVersioning",
"s3:ListBucket",
"s3:ListBucketVersions",
"s3:ListBucketMultipartUploads",
]
resources = [
"${aws_s3_bucket.gateway_bucket.arn}",
]
effect = "Allow"
}
statement {
actions = [
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:DeleteObjectVersion",
"s3:GetObject",
"s3:GetObjectVersion",
"s3:ListMultipartUploadParts",
"s3:PutObject",
]
resources = [
"${aws_s3_bucket.gateway_bucket.arn}/*",
]
effect = "Allow"
}
}
data "aws_iam_policy_document" "assume_role_policy_document" {
statement {
effect = "Allow"
principals {
identifiers = [
"storagegateway.amazonaws.com",
]
type = "Service"
}
actions = [
"sts:AssumeRole",
]
}
}
resource "aws_iam_policy" "iam_policy" {
name = "${var.application}-${var.environment}-${var.role}-bucket-access"
policy = "${data.aws_iam_policy_document.policy_document.json}"
}
resource "aws_iam_role_policy_attachment" "policy_attachment" {
role = "[your iam role ID goes here]" #todo enter this value
policy_arn = "${aws_iam_policy.iam_policy.arn}"
}