Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Add Egress S3 bucket to Analytical Platform Ingestion #5482

Merged
merged 11 commits into from
Mar 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,34 @@ module "s3_definitions_kms" {
deletion_window_in_days = 7
}

module "s3_bold_egress_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/bold-egress"]
description = "Used in the Bold Egress Solution"
enable_default_policy = true
key_statements = [
{
sid = "AllowAnalyticalPlatformDataEngineeringProduction"
actions = [
"kms:Encrypt",
"kms:GenerateDataKey"
]
resources = ["*"]
effect = "Allow"
principals = [
{
type = "AWS"
identifiers = ["arn:aws:iam::593291632749:role/mojap-data-production-bold-egress-${local.environment}"]
}
]
}
]
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
47 changes: 44 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,47 @@ module "processed_bucket" {
}
}
}

data "aws_iam_policy_document" "bold_egress_bucket_policy" {
statement {
sid = "ReplicationPermissions"
effect = "Allow"
principals {
type = "AWS"
identifiers = ["arn:aws:iam::593291632749:role/mojap-data-production-bold-egress-${local.environment}"]
}
actions = [
"s3:ReplicateObject",
"s3:ObjectOwnerOverrideToBucketOwner",
"s3:GetObjectVersionTagging",
"s3:ReplicateTags",
"s3:ReplicateDelete"
]
resources = ["arn:aws:s3:::mojap-ingestion-${local.environment}-bold-egress/*"]
}
}

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

bucket = "mojap-ingestion-${local.environment}-bold-egress"

force_destroy = true

versioning = {
enabled = true
}

attach_policy = true
policy = data.aws_iam_policy_document.bold_egress_bucket_policy.json

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