Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit maintenance window and backups #46

Merged
Merged
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
12 changes: 10 additions & 2 deletions terraform/prod/db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ resource "aws_db_instance" "dino_park_packs_db" {
password = "oneTimePassword"
db_subnet_group_name = aws_db_subnet_group.dino_park_packs_db.id
vpc_security_group_ids = [aws_security_group.dino_park_packs_db.id]
# Saturdays, at 3:00 AM (UTC); 7:00 PM (PST); 10:00 PM (EST) to
# 5:00 AM (UTC); 9:00 PM (PST); 12:00 AM (EST), respectively.
maintenance_window = "Sat:03:00-Sat:05:00"
# Backup every day at 2:00 AM (UTC); 6:00 PM (PST); 9:00 PM (EST) to
# 2:59 AM (UTC); 6:69 PM (PST); 9:59 PM (EST), respectively.
backup_window = "02:00-02:59"
backup_retention_period = "15" # days
copy_tags_to_snapshot = true
}

resource "aws_db_subnet_group" "dino_park_packs_db" {
name = "dino-park-packs-db-${var.environment}-${var.region}"
name = "dino-park-packs-db-${var.environment}-${var.region}"
description = "Subnet for DinoPark prod DB"
subnet_ids = flatten([data.terraform_remote_state.vpc.outputs.private_subnets])
}

resource "aws_security_group" "dino_park_packs_db" {
name = "dino-park-packs-db-${var.environment}-${var.region}"
name = "dino-park-packs-db-${var.environment}-${var.region}"
vpc_id = data.terraform_remote_state.vpc.outputs.vpc_id

ingress {
Expand Down
37 changes: 23 additions & 14 deletions terraform/test/db.tf
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
resource "aws_db_instance" "dino_park_packs_db" {
identifier = "dino-park-packs-db-${var.environment}-${var.region}"
allocated_storage = 10
max_allocated_storage = 100
storage_type = "gp2"
engine = "postgres"
engine_version = "11"
instance_class = "db.t3.micro"
allow_major_version_upgrade = true
username = "dinopark"
password = "oneTimePassword"
db_subnet_group_name = aws_db_subnet_group.dino_park_packs_db.id
vpc_security_group_ids = [aws_security_group.dino_park_packs_db.id]
identifier = "dino-park-packs-db-${var.environment}-${var.region}"
allocated_storage = 10
max_allocated_storage = 100
storage_type = "gp2"
engine = "postgres"
engine_version = "11"
instance_class = "db.t3.micro"
allow_major_version_upgrade = true
username = "dinopark"
password = "oneTimePassword"
db_subnet_group_name = aws_db_subnet_group.dino_park_packs_db.id
vpc_security_group_ids = [aws_security_group.dino_park_packs_db.id]
iam_database_authentication_enabled = true
# Saturdays, at 3:00 AM (UTC); 7:00 PM (PST); 10:00 PM (EST) to
# 5:00 AM (UTC); 9:00 PM (PST); 12:00 AM (EST), respectively.
maintenance_window = "Sat:03:00-Sat:05:00"
# Backup every day at 2:00 AM (UTC); 6:00 PM (PST); 9:00 PM (EST) to
# 2:59 AM (UTC); 6:69 PM (PST); 9:59 PM (EST), respectively.
backup_window = "02:00-02:59"
backup_retention_period = "15" # days
copy_tags_to_snapshot = true
}

resource "aws_db_subnet_group" "dino_park_packs_db" {
name = "dino-park-packs-db-${var.environment}-${var.region}"
name = "dino-park-packs-db-${var.environment}-${var.region}"
description = "Subnet for DinoPark test DB"
subnet_ids = flatten([data.terraform_remote_state.vpc.outputs.private_subnets])
}

resource "aws_security_group" "dino_park_packs_db" {
name = "dino-park-packs-db-${var.environment}-${var.region}"
name = "dino-park-packs-db-${var.environment}-${var.region}"
vpc_id = data.terraform_remote_state.vpc.outputs.vpc_id

ingress {
Expand Down
Loading