Skip to content

Commit

Permalink
fix(infra): infra
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-h1 committed Jan 2, 2025
1 parent f3e1716 commit a82d708
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
7 changes: 6 additions & 1 deletion terraform/app-runner.tf
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ resource "aws_apprunner_service" "app_runner_service" {
}

runtime_environment_variables = {
DATABASE_URL = var.database_url
DATABASE_URL = format(
"postgres://%s:%s@%s?sslmode=verify-full",
urlencode(aws_rds_cluster.db.master_username),
urlencode(aws_rds_cluster.db.master_password),
aws_rds_cluster.db.endpoint
)
API_BASE_URL = "${var.api_base_url}"
DEPLOYED_BY = "${var.deployed_by}"
DEPLOYED_AT = "${var.deployed_at}"
Expand Down
9 changes: 0 additions & 9 deletions terraform/db-vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ resource "aws_db_subnet_group" "db" {
}
}

# see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
resource "aws_security_group" "db" {
vpc_id = aws_vpc.db_vpc.id
name = "db"
description = "PostgreSQL Database"
tags = {
Name = "${var.project_name}-db"
}
}

# see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_ingress_rule
resource "aws_vpc_security_group_ingress_rule" "db_postgresql" {
Expand Down
19 changes: 19 additions & 0 deletions terraform/db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ locals {
)
}

resource "aws_security_group" "db" {
name = "${var.project_name}-${var.env}-db-sg"
vpc_id = aws_default_vpc.default_vpc.id

ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
security_groups = [aws_security_group.app_runner_sg.id]
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}


data "aws_availability_zones" "available" {}

Expand Down

0 comments on commit a82d708

Please sign in to comment.