Skip to content

Commit b465e2b

Browse files
committed
NRL-853 combine dynamodb and s3 policies, protect access to report bucket
1 parent b00d598 commit b465e2b

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

terraform/account-wide-infrastructure/dev/aws-backups.tf

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ resource "aws_s3_bucket" "backup_reports" {
3737
bucket_prefix = "${local.project_name}-backup-reports"
3838
}
3939

40+
resource "aws_s3_bucket_public_access_block" "backup_reports" {
41+
bucket = aws_s3_bucket.backup_reports.id
42+
43+
block_public_acls = true
44+
block_public_policy = true
45+
ignore_public_acls = true
46+
restrict_public_buckets = true
47+
}
48+
49+
resource "aws_s3_bucket_server_side_encryption_configuration" "backup_reports" {
50+
bucket = aws_s3_bucket.backup_reports.bucket
51+
52+
rule {
53+
apply_server_side_encryption_by_default {
54+
sse_algorithm = "AES256"
55+
}
56+
}
57+
}
4058
# Now we have to configure access to the report bucket.
4159

4260
resource "aws_s3_bucket_ownership_controls" "backup_reports" {
@@ -108,7 +126,7 @@ module "source" {
108126

109127
backup_plan_config = {
110128
"compliance_resource_types" : [
111-
"S3"
129+
"S3", "DynamoDB"
112130
],
113131
"rules" : [
114132
{
@@ -124,15 +142,4 @@ module "source" {
124142
],
125143
"selection_tag" : "NHSE-Enable-Backup"
126144
}
127-
# Note here that we need to explicitly disable DynamoDB backups in the source account.
128-
# The default config in the module enables backups for all resource types.
129-
backup_plan_config_dynamodb = {
130-
"compliance_resource_types" : [
131-
"DynamoDB"
132-
],
133-
"rules" : [
134-
],
135-
"enable" : false,
136-
"selection_tag" : "NHSE-Enable-Backup"
137-
}
138145
}

0 commit comments

Comments
 (0)