Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,23 @@ resource "aws_db_instance" "self" {
Project = var.name
}
}

resource "aws_db_instance" "read_replica" {
count = var.create_readreplica ? 1 : 0

identifier = "${var.name}-${var.env}-db-readreplica"
allocated_storage = 5
max_allocated_storage = 20
storage_encrypted = true
engine = "postgres"
instance_class = var.instance_type_read_replica
replicate_source_db = aws_db_instance.self.identifier
skip_final_snapshot = true
availability_zone = var.azs[0]
db_subnet_group_name = aws_db_subnet_group.self.name
vpc_security_group_ids = [aws_security_group.db.id]

tags = {
Project = var.name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ variable "vpc_cidr" {}
variable "subnets" {}
variable "azs" {}
variable "instance_type" {}
variable "instance_type_read_replica" {}

variable "create_readreplica" {
type = bool
description = "Create readreplica? (true/false) default: false"
default = false
}