Page MenuHomePhabricator

D12298.id40909.diff
No OneTemporary

D12298.id40909.diff

diff --git a/services/terraform/self-host/aws_db.tf b/services/terraform/self-host/aws_db.tf
new file mode 100644
--- /dev/null
+++ b/services/terraform/self-host/aws_db.tf
@@ -0,0 +1,40 @@
+# MariaDB Security Group
+resource "aws_security_group" "keyserver_mariadb_security_group" {
+ name = "keyserver-mariadb-sg"
+ description = "Allow inbound traffic on port 3307 and all outbound traffic"
+ vpc_id = aws_vpc.default.id
+
+ # Inbound rules
+ ingress {
+ from_port = 3307
+ to_port = 3307
+ protocol = "tcp"
+ cidr_blocks = ["0.0.0.0/0"] # Allow from anywhere, you can modify this to specific IPs or ranges
+ }
+
+ # Outbound rules
+ egress {
+ from_port = 0
+ to_port = 0
+ protocol = "-1"
+ cidr_blocks = ["0.0.0.0/0"]
+ }
+}
+
+
+# MariaDB RDS Instance
+resource "aws_db_instance" "mariadb" {
+ allocated_storage = 5
+ db_name = "mariadb"
+ identifier = "mariadb-instance"
+ engine = "mariadb"
+ engine_version = "10.11"
+ instance_class = "db.t3.micro"
+ db_subnet_group_name = aws_db_subnet_group.private-db-subnet-group.name
+ vpc_security_group_ids = [aws_security_group.keyserver_mariadb_security_group.id]
+ username = local.secrets["mariaDB"]["username"]
+ password = local.secrets["mariaDB"]["password"]
+ parameter_group_name = "default.mariadb10.11"
+ port = 3307
+ skip_final_snapshot = true
+}
diff --git a/services/terraform/self-host/aws_vpc.tf b/services/terraform/self-host/aws_vpc.tf
--- a/services/terraform/self-host/aws_vpc.tf
+++ b/services/terraform/self-host/aws_vpc.tf
@@ -42,3 +42,13 @@
availability_zone = "us-east-2c"
map_public_ip_on_launch = false
}
+
+# DB Subnet Group
+resource "aws_db_subnet_group" "private-db-subnet-group" {
+ name = "private-db-subnet-group"
+ subnet_ids = [aws_subnet.private_b.id, aws_subnet.private_c.id]
+
+ tags = {
+ Name = "DB subnet group associated with private vpc subnet"
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 5, 11:54 PM (21 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2246960
Default Alt Text
D12298.id40909.diff (2 KB)

Event Timeline