Skip to content

Commit

Permalink
WIP - Add S3 bucket, KMS, custom policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary-H9 committed Mar 26, 2024
1 parent 09ef147 commit 6d5754e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
9 changes: 9 additions & 0 deletions terraform/environments/analytical-platform-ingestion/data.tf
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
#### This file can be used to store data specific to the member account ####
data "aws_availability_zones" "available" {}

data "aws_iam_policy_document" "s3_download_kms_policy" {
statement {
sid = "AllowS3Download"
effect = "Allow"
actions = ["kms:Decrypt"]
resources = ["*"]
}
}
12 changes: 12 additions & 0 deletions terraform/environments/analytical-platform-ingestion/kms-keys.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ module "s3_definitions_kms" {
deletion_window_in_days = 7
}

module "s3_download_kms" {
#checkov:skip=CKV_TF_1:Module registry does not support commit hashes for versions
source = "terraform-aws-modules/kms/aws"
version = "2.2.1"

aliases = ["s3/download"]
description = "Used in the download S3 object"
enable_default_policy = true

deletion_window_in_days = 7
}

module "sns_kms" {
#checkov:skip=CKV_TF_1:Module registry does not support commit hashes for versions
source = "terraform-aws-modules/kms/aws"
Expand Down
22 changes: 19 additions & 3 deletions terraform/environments/analytical-platform-ingestion/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module "quarantine_bucket" {
}
}


module "definitions_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "4.1.0"
Expand All @@ -53,8 +52,6 @@ module "definitions_bucket" {
}
}



module "processed_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "4.1.0"
Expand All @@ -72,3 +69,22 @@ module "processed_bucket" {
}
}
}

module "download_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "4.1.0"

bucket = "mojap-ingestion-${local.environment}-download"
# TODO: Is this needed below?
force_destroy = true
policy = data.aws_iam_policy_document.s3_download_kms_policy.json

server_side_encryption_configuration = {
rule = {
apply_server_side_encryption_by_default = {
kms_master_key_id = module.s3_processed_kms.key_arn
sse_algorithm = "aws:kms"
}
}
}
}

0 comments on commit 6d5754e

Please sign in to comment.