This repository has been archived by the owner on Sep 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3_bucket.tf
74 lines (70 loc) · 2.08 KB
/
s3_bucket.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
resource "aws_s3_bucket" "valtix_s3_bucket" {
bucket = var.s3_bucket
force_destroy = true
acl = "private"
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_s3_bucket_policy" "valtix_s3_bucket_policy" {
bucket = aws_s3_bucket.valtix_s3_bucket.id
policy = jsonencode({
Version = "2012-10-17"
Id = "MYBUCKETPOLICY"
Statement = [
{
"Action" : "s3:GetBucketAcl",
"Effect" : "Allow",
"Resource" : aws_s3_bucket.valtix_s3_bucket.arn,
"Principal" : {
"Service" : "cloudtrail.amazonaws.com"
}
},
{
"Action" : "s3:PutObject",
"Effect" : "Allow",
"Resource" : "${aws_s3_bucket.valtix_s3_bucket.arn}/AWSLogs/${data.aws_caller_identity.current.account_id}/*",
"Principal" : {
"Service" : "cloudtrail.amazonaws.com"
},
"Condition" : {
"StringEquals" : {
"s3:x-amz-acl" : "bucket-owner-full-control"
}
}
},
{
"Action" : "s3:GetBucketAcl",
"Effect" : "Allow",
"Resource" : aws_s3_bucket.valtix_s3_bucket.arn,
"Principal" : {
"Service" : "delivery.logs.amazonaws.com"
}
},
{
"Action" : "s3:PutObject",
"Effect" : "Allow",
"Resource" : "${aws_s3_bucket.valtix_s3_bucket.arn}/AWSLogs/${data.aws_caller_identity.current.account_id}/*",
"Principal" : {
"Service" : "delivery.logs.amazonaws.com"
},
"Condition" : {
"StringEquals" : {
"s3:x-amz-acl" : "bucket-owner-full-control"
}
}
}
]
})
}
resource "aws_s3_bucket_notification" "valtix_s3_bucket_notification" {
bucket = aws_s3_bucket.valtix_s3_bucket.id
queue {
queue_arn = "arn:aws:sqs:${data.aws_region.current.name}:${var.controller_aws_account_number}:inventory_logs_queue_${var.deployment_name}_${data.aws_region.current.name}"
events = ["s3:ObjectCreated:*"]
}
}