Skip to content

Commit

Permalink
Update rds secret with url
Browse files Browse the repository at this point in the history
  • Loading branch information
shri committed Aug 12, 2024
1 parent 929a3af commit 80cb8dc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion deploy/aws/tf/modules/rds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,15 @@ resource "aws_db_instance" "app_db" {
depends_on = [var.vpc_id, aws_secretsmanager_secret.app_db_password]
}

# TODO: Append rds host to secretsmanager
locals {
current_secret = jsondecode(data.aws_secretsmanager_secret_version.app_db_password_version_data.secret_string)
encoded_password = urlencode(jsondecode(data.aws_secretsmanager_secret_version.app_db_password_version_data.secret_string).password)
new_secret = merge(local.current_secret, { url = "postgresql+asyncpg://${var.app_db_user}:${local.encoded_password}@${aws_db_instance.app_db.endpoint}:5432/${var.app_db_name}" })

depends_on = [data.aws_secretsmanager_secret_version.app_db_password_version_data]
}

resource "aws_secretsmanager_secret_version" "update_app_db_password_version_data" {
secret_id = aws_secretsmanager_secret.app_db_password.id
secret_string = jsonencode(local.new_secret)
}

0 comments on commit 80cb8dc

Please sign in to comment.