diff --git a/infra/audit_db.tf b/infra/audit_db.tf index 7e4858a2..a1548f99 100644 --- a/infra/audit_db.tf +++ b/infra/audit_db.tf @@ -22,5 +22,8 @@ resource "aws_dynamodb_table" "audit-table" { point_in_time_recovery { enabled = local.environment == "prod" ? true : false } - + server_side_encryption { + enabled = true + kms_key_arn = data.aws_kms_key.existing_dynamo_encryption_arn.arn + } } \ No newline at end of file diff --git a/infra/delta_db.tf b/infra/delta_db.tf index b1b0f374..7f052bff 100644 --- a/infra/delta_db.tf +++ b/infra/delta_db.tf @@ -47,4 +47,8 @@ resource "aws_dynamodb_table" "delta-dynamodb-table" { point_in_time_recovery { enabled = local.environment == "prod" ? true : false } + server_side_encryption { + enabled = true + kms_key_arn = data.aws_kms_key.existing_dynamo_encryption_arn.arn + } } \ No newline at end of file diff --git a/infra/endpoints.tf b/infra/endpoints.tf index 0ed29040..762c0058 100644 --- a/infra/endpoints.tf +++ b/infra/endpoints.tf @@ -1,18 +1,33 @@ resource "aws_security_group" "lambda_redis_sg" { vpc_id = data.aws_vpc.default.id name = "immunisation-security-group" + + # Inbound rule to allow traffic only from the VPC CIDR block ingress { from_port = 0 to_port = 0 protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] + cidr_blocks = ["172.31.0.0/16"] } + # Outbound rules to specific AWS services using prefix lists egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] + from_port = 0 + to_port = 0 + protocol = "-1" + prefix_list_ids = [ + "pl-7ca54015", + "pl-93a247fa", + "pl-b3a742da" + ] + } + + # Egress rule to allow communication within the same security group + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + self = true } } diff --git a/infra/imms_db.tf b/infra/imms_db.tf index 699c80f0..f7ef0e98 100644 --- a/infra/imms_db.tf +++ b/infra/imms_db.tf @@ -42,4 +42,8 @@ resource "aws_dynamodb_table" "events-dynamodb-table" { point_in_time_recovery { enabled = local.environment == "prod" ? true : false } + server_side_encryption { + enabled = true + kms_key_arn = data.aws_kms_key.existing_dynamo_encryption_arn.arn + } } \ No newline at end of file diff --git a/infra/kms_dynamo.tf b/infra/kms_dynamo.tf new file mode 100644 index 00000000..eaab9304 --- /dev/null +++ b/infra/kms_dynamo.tf @@ -0,0 +1,66 @@ + resource "aws_kms_key" "dynamodb_encryption" { + description = "KMS key for DynamoDB encryption" + key_usage = "ENCRYPT_DECRYPT" + enable_key_rotation = true + policy = <