-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodule_s3bucket_pii_data.tf
More file actions
89 lines (74 loc) · 1.93 KB
/
module_s3bucket_pii_data.tf
File metadata and controls
89 lines (74 loc) · 1.93 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
module "s3bucket_pii_data" {
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/terraform/modules/s3bucket?ref=feature/CCM-16776_s3_pii_access" #Change this later to actual tag
name = "pii-data"
aws_account_id = var.aws_account_id
region = var.region
project = var.project
environment = var.environment
component = local.component
kms_key_arn = module.kms.key_arn
enable_abac = var.restrict_pii_data_access ? true : false
policy_documents = [data.aws_iam_policy_document.s3bucket_pii_data.json]
force_destroy = var.force_destroy
default_tags = {
NHSE-Enable-S3-Backup-Acct = "True",
NHSE-PII-Data = "True",
}
}
data "aws_iam_policy_document" "s3bucket_pii_data" {
statement {
sid = "AllowManagedAccountsToList"
effect = "Allow"
actions = [
"s3:ListBucket",
]
resources = [
module.s3bucket_pii_data.arn,
]
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${var.aws_account_id}:root"
]
}
}
statement {
sid = "AllowManagedAccountsToGet"
effect = "Allow"
actions = [
"s3:GetObject",
"s3:PutObject",
]
resources = [
"${module.s3bucket_pii_data.arn}/*",
]
principals {
type = "AWS"
identifiers = [
"arn:aws:iam::${var.aws_account_id}:root"
]
}
}
# dynamic "statement" {
# for_each = var.restrict_pii_data_access ? [1] : []
# content {
# effect = "Deny"
# actions = [
# "s3:GetObject",
# "s3:GetObjectVersion",
# "s3:PutObject",
# "s3:DeleteObject"
# ]
# resources = [
# module.s3bucket_pii_data.arn,
# "${module.s3bucket_pii_data.arn}/*",
# ]
# principals {
# type = "AWS"
# identifiers = [
# local.bc_restricted_dev_role
# ]
# }
# }
# }
}