Skip to content

Commit ca5d724

Browse files
committed
feat(athena): FDOS-614 Add Athena stack with DynamoDB and RDS connectors
1 parent 6c35309 commit ca5d724

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
locals {
22
stack_enabled = var.athena_stack_enabled ? 1 : 0
3+
rds_secret = local.stack_enabled == 1 && local.is_primary_environment ? jsondecode(data.aws_secretsmanager_secret_version.target_rds_credentials[0].secret_string) : null
34
}

infrastructure/stacks/athena/data.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ data "aws_lambda_function" "rds_lambda_connector" {
3434
data "aws_security_group" "dms_replication_security_group" {
3535
name = "${local.project_prefix}-account-wide-etl-replication-sg"
3636
}
37+
38+
data "aws_secretsmanager_secret" "target_rds_credentials" {
39+
count = local.stack_enabled == 1 && local.is_primary_environment ? 1 : 0
40+
name = "/${var.project}/${var.environment}/${var.target_rds_credentials}"
41+
}
42+
43+
data "aws_secretsmanager_secret_version" "target_rds_credentials" {
44+
count = local.stack_enabled == 1 && local.is_primary_environment ? 1 : 0
45+
secret_id = data.aws_secretsmanager_secret.target_rds_credentials[0].id
46+
}

infrastructure/stacks/athena/security_group.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ resource "aws_vpc_security_group_egress_rule" "rds_connector_allow_egress_to_rds
1818
to_port = var.rds_port
1919
}
2020

21+
# trivy:ignore:aws-vpc-no-public-egress-sgr : Justification: This security group is for the Athena RDS Connector Lambda, which requires egress access to the internet for S3 and Secrets Manager, as well as access to the RDS instance.
2122
resource "aws_vpc_security_group_egress_rule" "rds_connector_allow_egress_https" {
2223
count = local.stack_enabled == 1 && local.is_primary_environment ? 1 : 0
2324

infrastructure/stacks/athena/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ variable "athena_dynamodb_connector_app_id" {
2121
type = string
2222
default = "arn:aws:serverlessrepo:us-east-1:292517598671:applications/AthenaDynamoDBConnector"
2323
}
24+
25+
variable "target_rds_credentials" {
26+
description = "The secrets manager name for the target RDS credentials"
27+
type = string
28+
default = "target-rds-credentials"
29+
}

infrastructure/stacks/data_migration/data.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,5 @@ data "aws_security_group" "processor_lambda_security_group" {
290290

291291
data "aws_security_group" "rds_connector_security_group" {
292292
count = var.athena_stack_enabled && local.is_primary_environment ? 1 : 0
293-
name = "${local.account_prefix}-rds-connector-sg"
293+
name = "${local.project_prefix}-athena-rds-connector-sg"
294294
}

infrastructure/stacks/data_migration/security_group.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ resource "aws_vpc_security_group_egress_rule" "rds_allow_egress_to_internet" {
9595
}
9696

9797
resource "aws_vpc_security_group_ingress_rule" "rds_allow_ingress_from_athena_connector" {
98-
count = var.athena_stack_enabled && local.is_primary_environment ? 1 : 0
98+
count = (var.athena_stack_enabled && local.is_primary_environment) ? 1 : 0
9999
security_group_id = try(aws_security_group.rds_security_group[0].id, data.aws_security_group.rds_security_group[0].id)
100100
referenced_security_group_id = data.aws_security_group.rds_connector_security_group[0].id
101101
description = "Allow incoming Postgres from Athena RDS Connector Lambda"

0 commit comments

Comments
 (0)