-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy paths3_source_bucket.tf
More file actions
73 lines (66 loc) · 1.88 KB
/
s3_source_bucket.tf
File metadata and controls
73 lines (66 loc) · 1.88 KB
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
# Overall entry point into batch in prod. Files are forwarded into the appropriate blue / green bucket.
resource "aws_s3_bucket" "batch_data_source_bucket" {
count = var.blue_green_split ? 1 : 0
bucket = "immunisation-batch-${var.environment}-data-sources"
}
resource "aws_s3_bucket_public_access_block" "batch_data_source_bucket_public_access_block" {
count = var.blue_green_split ? 1 : 0
bucket = aws_s3_bucket.batch_data_source_bucket[0].id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
resource "aws_s3_bucket_policy" "batch_data_source_bucket_policy" {
count = var.blue_green_split ? 1 : 0
bucket = aws_s3_bucket.batch_data_source_bucket[0].bucket
policy = jsonencode({
Version : "2012-10-17",
Statement : [
{
Effect : "Allow",
Principal : {
AWS : "arn:aws:iam::${var.dspp_account_id}:root"
},
Action : [
"s3:PutObject"
],
Resource : [
aws_s3_bucket.batch_data_source_bucket[0].arn,
"${aws_s3_bucket.batch_data_source_bucket[0].arn}/*"
]
},
{
Sid = "HTTPSOnly"
Effect = "Deny"
Principal = {
"AWS" : "*"
}
Action = "s3:*"
Resource = [
aws_s3_bucket.batch_data_source_bucket[0].arn,
"${aws_s3_bucket.batch_data_source_bucket[0].arn}/*",
]
Condition = {
Bool = {
"aws:SecureTransport" = "false"
}
}
},
]
})
}
resource "aws_s3_bucket_lifecycle_configuration" "datasources_lifecycle" {
count = var.blue_green_split ? 1 : 0
bucket = aws_s3_bucket.batch_data_source_bucket[0].bucket
rule {
id = "DeleteFilesAfter7Days"
status = "Enabled"
filter {
prefix = "*"
}
expiration {
days = 7
}
}
}