-
Notifications
You must be signed in to change notification settings - Fork 1
/
s3.tf
65 lines (55 loc) · 1.19 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
62
63
64
65
#
# lambda function
#
resource "aws_s3_bucket" "lambda-function" {
count = local.on_common ? 1 : 0
bucket = local.lambda_bucket
acl = "log-delivery-write"
lifecycle_rule {
enabled = true
transition {
days = 30
storage_class = "GLACIER"
}
expiration {
days = 365
}
}
versioning {
enabled = true
}
force_destroy = true
policy = <<JSON
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::${var.service_account_id}:root"
},
"Action": [
"s3:Get*",
"s3:List*",
"s3:Put*",
"s3:Delete*"
],
"Resource": [
"arn:aws:s3:::${local.lambda_bucket}/*"
]
}
]
}
JSON
tags = {
service = local.service_name
}
}
resource "aws_s3_bucket_public_access_block" "lambda-function" {
count = local.on_common ? 1 : 0
bucket = aws_s3_bucket.lambda-function[0].id
block_public_acls = true
ignore_public_acls = true
block_public_policy = true
restrict_public_buckets = true
}