-
Notifications
You must be signed in to change notification settings - Fork 0
/
acl.tf
38 lines (34 loc) · 935 Bytes
/
acl.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
resource "aws_s3_bucket_ownership_controls" "bucket_acl" {
count = var.create && var.create_iam_user && var.create_iam_user_write_acl ? 1 : 0
bucket = aws_s3_bucket.bucket[0].id
rule {
object_ownership = "ObjectWriter"
}
}
resource "aws_s3_bucket_acl" "grant_owner_to_iam" {
count = var.create && var.create_iam_user && var.create_iam_user_write_acl ? 1 : 0
depends_on = [
aws_s3_bucket_ownership_controls.bucket_acl[0],
aws_iam_user.bucket_user[0],
]
bucket = aws_s3_bucket.bucket[0].id
access_control_policy {
grant {
grantee {
id = data.aws_canonical_user_id.current.id
type = "CanonicalUser"
}
permission = "WRITE_ACP"
}
grant {
grantee {
type = "Group"
uri = "http://acs.amazonaws.com/groups/s3/LogDelivery"
}
permission = "READ_ACP"
}
owner {
id = data.aws_canonical_user_id.current.id
}
}
}