Skip to content

Commit d4bbb9a

Browse files
authored
Merge pull request #46 from bheesham/explicit-maintenance-window-and-backups
Add explicit maintenance window and backups
2 parents 9dd5a1f + 10ff1b9 commit d4bbb9a

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

terraform/prod/db.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,24 @@ resource "aws_db_instance" "dino_park_packs_db" {
1111
password = "oneTimePassword"
1212
db_subnet_group_name = aws_db_subnet_group.dino_park_packs_db.id
1313
vpc_security_group_ids = [aws_security_group.dino_park_packs_db.id]
14+
# Saturdays, at 3:00 AM (UTC); 7:00 PM (PST); 10:00 PM (EST) to
15+
# 5:00 AM (UTC); 9:00 PM (PST); 12:00 AM (EST), respectively.
16+
maintenance_window = "Sat:03:00-Sat:05:00"
17+
# Backup every day at 2:00 AM (UTC); 6:00 PM (PST); 9:00 PM (EST) to
18+
# 2:59 AM (UTC); 6:69 PM (PST); 9:59 PM (EST), respectively.
19+
backup_window = "02:00-02:59"
20+
backup_retention_period = "15" # days
21+
copy_tags_to_snapshot = true
1422
}
1523

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

2230
resource "aws_security_group" "dino_park_packs_db" {
23-
name = "dino-park-packs-db-${var.environment}-${var.region}"
31+
name = "dino-park-packs-db-${var.environment}-${var.region}"
2432
vpc_id = data.terraform_remote_state.vpc.outputs.vpc_id
2533

2634
ingress {

terraform/test/db.tf

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
resource "aws_db_instance" "dino_park_packs_db" {
2-
identifier = "dino-park-packs-db-${var.environment}-${var.region}"
3-
allocated_storage = 10
4-
max_allocated_storage = 100
5-
storage_type = "gp2"
6-
engine = "postgres"
7-
engine_version = "11"
8-
instance_class = "db.t3.micro"
9-
allow_major_version_upgrade = true
10-
username = "dinopark"
11-
password = "oneTimePassword"
12-
db_subnet_group_name = aws_db_subnet_group.dino_park_packs_db.id
13-
vpc_security_group_ids = [aws_security_group.dino_park_packs_db.id]
2+
identifier = "dino-park-packs-db-${var.environment}-${var.region}"
3+
allocated_storage = 10
4+
max_allocated_storage = 100
5+
storage_type = "gp2"
6+
engine = "postgres"
7+
engine_version = "11"
8+
instance_class = "db.t3.micro"
9+
allow_major_version_upgrade = true
10+
username = "dinopark"
11+
password = "oneTimePassword"
12+
db_subnet_group_name = aws_db_subnet_group.dino_park_packs_db.id
13+
vpc_security_group_ids = [aws_security_group.dino_park_packs_db.id]
14+
iam_database_authentication_enabled = true
15+
# Saturdays, at 3:00 AM (UTC); 7:00 PM (PST); 10:00 PM (EST) to
16+
# 5:00 AM (UTC); 9:00 PM (PST); 12:00 AM (EST), respectively.
17+
maintenance_window = "Sat:03:00-Sat:05:00"
18+
# Backup every day at 2:00 AM (UTC); 6:00 PM (PST); 9:00 PM (EST) to
19+
# 2:59 AM (UTC); 6:69 PM (PST); 9:59 PM (EST), respectively.
20+
backup_window = "02:00-02:59"
21+
backup_retention_period = "15" # days
22+
copy_tags_to_snapshot = true
1423
}
1524

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

2231
resource "aws_security_group" "dino_park_packs_db" {
23-
name = "dino-park-packs-db-${var.environment}-${var.region}"
32+
name = "dino-park-packs-db-${var.environment}-${var.region}"
2433
vpc_id = data.terraform_remote_state.vpc.outputs.vpc_id
2534

2635
ingress {

0 commit comments

Comments
 (0)