-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
61 lines (56 loc) · 1.52 KB
/
s3.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" "s3_for_github" {
statement {
sid = "AllowListDescribe"
effect = "Allow"
actions = [
"s3:GetAccelerateConfiguration",
"s3:GetBucketAcl",
"s3:GetBucketCORS",
"s3:GetBucketLocation",
"s3:GetBucketLogging",
"s3:GetBucketNotification",
"s3:GetBucketObjectLockConfiguration",
"s3:GetBucketPolicy",
"s3:GetBucketPolicyStatus",
"s3:GetBucketPublicAccessBlock",
"s3:GetBucketRequestPayment",
"s3:GetBucketTagging",
"s3:GetBucketVersioning",
"s3:GetBucketWebsite",
"s3:GetEncryptionConfiguration",
"s3:GetIntelligentTieringConfiguration",
"s3:GetLifecycleConfiguration",
"s3:GetMetricsConfiguration",
"s3:ListAllMyBuckets",
"s3:ListBucket",
"s3:ListBucketVersions",
"s3:GetReplicationConfiguration"
]
resources = ["*"]
}
statement {
sid = "AllowGetOwn"
effect = "Allow"
actions = [
"s3:ListBucket*",
"s3:GetObject*"
]
resources = ["*"]
condition {
test = "StringLike"
variable = "aws:PrincipalTag/GithubTeam"
values = ["*:$${s3:ExistingObjectTag/GithubTeam}:*"]
}
}
}
resource "aws_iam_policy" "s3_for_github" {
policy = data.aws_iam_policy_document.s3_for_github.json
name = "s3-for-github"
tags = {
GithubTeam = "webops"
}
}
resource "aws_iam_role_policy_attachment" "s3_for_github" {
role = aws_iam_role.github_access.name
policy_arn = aws_iam_policy.s3_for_github.arn
}