Skip to content

Commit

Permalink
infra: add rds instance
Browse files Browse the repository at this point in the history
  • Loading branch information
nkordis committed May 30, 2024
1 parent 2b66bf3 commit 8418f72
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 207 deletions.
53 changes: 53 additions & 0 deletions infra/deploy/database.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
############
# Database #
############

resource "aws_db_subnet_group" "main" {
name = "${local.prefix}-main"
subnet_ids = [
aws_subnet.private_a.id,
aws_subnet.private_b.id
]

tags = {
Name = "${local.prefix}-db-subnet-group"
}
}

resource "aws_security_group" "rds" {
description = "Allow access to the RDS database instance"
name = "${local.prefix}-rds-inbound-access"
vpc_id = aws_vpc.main.id

ingress {
protocol = "tcp"
from_port = 5432
to_port = 5432
}

tags = {
Name = "${local.prefix}-rds-security-group"
}
}

resource "aws_db_instance" "main" {
identifier = "${local.prefix}-db"
db_name = "projects"
allocated_storage = 20
storage_type = "gp2"
engine = "postgres"
engine_version = "15.3"
auto_minor_version_upgrade = true
instance_class = "db.t4g.micro"
username = var.db_username
password = var.db_password
skip_final_snapshot = true
db_subnet_group_name = aws_db_subnet_group.main.name
multi_az = false
backup_retention_period = 0
vpc_security_group_ids = [aws_security_group.rds.id]

tags = {
Name = "${local.prefix}-main"
}
}
Loading

0 comments on commit 8418f72

Please sign in to comment.