generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_s3bucket_lambda_function_artefacts.tf
129 lines (103 loc) · 2.29 KB
/
module_s3bucket_lambda_function_artefacts.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
module "s3bucket_lambda_artefacts" {
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/s3bucket?ref=v1.0.8"
providers = {
aws = aws.us-east-1
}
name = "lambda-artefacts"
aws_account_id = var.aws_account_id
region = "us-east-1"
project = var.project
environment = var.environment
component = var.component
acl = "private"
force_destroy = false
versioning = true
lifecycle_rules = [
{
prefix = ""
enabled = true
noncurrent_version_transition = [
{
noncurrent_days = "30"
storage_class = "STANDARD_IA"
}
]
noncurrent_version_expiration = {
noncurrent_days = "90"
}
abort_incomplete_multipart_upload = {
days = "1"
}
}
]
policy_documents = [
data.aws_iam_policy_document.s3bucket_lambda_artefacts.json
]
public_access = {
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
default_tags = {
Name = "Lambda function artefact bucket"
}
}
data "aws_iam_policy_document" "s3bucket_lambda_artefacts" {
statement {
sid = "DontAllowNonSecureConnection"
effect = "Deny"
actions = [
"s3:*",
]
resources = [
module.s3bucket_lambda_artefacts.arn,
"${module.s3bucket_lambda_artefacts.arn}/*",
]
principals {
type = "AWS"
identifiers = [
"*",
]
}
condition {
test = "Bool"
variable = "aws:SecureTransport"
values = [
"false",
]
}
}
statement {
sid = "AllowManagedAccountsToList"
effect = "Allow"
actions = [
"s3:ListBucket",
]
resources = [
module.s3bucket_lambda_artefacts.arn,
]
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${var.aws_account_id}:root"
]
}
}
statement {
sid = "AllowManagedAccountsToGet"
effect = "Allow"
actions = [
"s3:GetObject",
]
resources = [
"${module.s3bucket_lambda_artefacts.arn}/*",
]
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${var.aws_account_id}:root"
]
}
}
}