Skip to content

Commit

Permalink
PLT-728 update state and tf to postgres upgrade (#146)
Browse files Browse the repository at this point in the history
## 🎫 Ticket

https://jira.cms.gov/browse/PLT-728

## 🛠 Changes

Updating TF to match current AWS state per Postgres 16 upgrade work plan

## ℹ️ Context

Due to technical issues with Postgres 16.4 upgrade there were some
settings changed via console and this pull is intended to realign
terraform with the intended settings.

<!-- If any of the following security implications apply, this PR must
not be merged without Stephen Walter's approval. Explain in this section
and add @SJWalter11 as a reviewer.
  - Adds a new software dependency or dependencies.
  - Modifies or invalidates one or more of our security controls.
  - Stores or transmits data that was not stored or transmitted before.
- Requires additional review of security implications for other reasons.
-->

## 🧪 Validation

Local TF plan & TF refresh-only updates for state file; also validating
via GHA plan
  • Loading branch information
ildesenesence authored Nov 15, 2024
1 parent 96ccd34 commit 78c7894
Showing 1 changed file with 3 additions and 58 deletions.
61 changes: 3 additions & 58 deletions terraform/services/api-rds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@ locals {
bcda = "${var.app}-${var.env}"
dpc = "${var.app}-${var.env}"
}[var.app]
postgres_ver = {
ab2d = {
dev = 15
test = 15
sbx = 15
prod = 15
}[var.env]
bcda = {
dev = 15
test = 15
sbx = 15
prod = 15
}[var.env]
dpc = {
dev = 14
test = 14
sbx = 14
prod = 14
}[var.env]
}[var.app]
}

## Begin module/main.tf
Expand Down Expand Up @@ -83,41 +63,6 @@ resource "aws_db_subnet_group" "subnet_group" {

# Create database parameter group

resource "aws_db_parameter_group" "parameter_group" {
name = "${local.db_name}-rds-parameter-group-v15"
family = "postgres15"

parameter {
name = "backslash_quote"
value = "safe_encoding"
apply_method = "immediate"
}
parameter {
name = "shared_preload_libraries"
value = "pg_stat_statements,pg_cron"
apply_method = "pending-reboot"
}
parameter {
name = "cron.database_name"
value = var.app == "ab2d" && var.env == "test" ? "impl" : var.env
apply_method = "pending-reboot"
}
parameter {
name = "statement_timeout"
value = "1200000"
apply_method = "immediate"
}
parameter {
name = "rds.logical_replication"
value = 0 # contains(["ab2d-dev", "ab2d-east-impl"], local.db_name) ? "1" : "0" # To support blue-green deployment for PostGres16 upgrade
apply_method = "pending-reboot"
}

lifecycle {
create_before_destroy = true
}
}

resource "aws_db_parameter_group" "v16_parameter_group" {
name = "${local.db_name}-rds-parameter-group-v16"
family = "postgres16"
Expand All @@ -144,7 +89,7 @@ resource "aws_db_parameter_group" "v16_parameter_group" {
}
parameter {
name = "rds.logical_replication"
value = 0 # contains(["ab2d-dev", "ab2d-east-impl"], local.db_name) ? "1" : "0" # To support blue-green deployment for PostGres16 upgrade
value = 0
apply_method = "pending-reboot"
}

Expand All @@ -158,7 +103,7 @@ resource "aws_db_parameter_group" "v16_parameter_group" {
resource "aws_db_instance" "api" {
allocated_storage = 500
engine = "postgres"
engine_version = local.postgres_ver
engine_version = 16
instance_class = "db.m6i.2xlarge"
identifier = local.db_name
storage_encrypted = true
Expand All @@ -170,7 +115,7 @@ resource "aws_db_instance" "api" {
skip_final_snapshot = true

db_subnet_group_name = aws_db_subnet_group.subnet_group.name
parameter_group_name = aws_db_parameter_group.parameter_group.name # contains(["ab2d-dev", "ab2d-east-impl"], local.db_name) ? aws_db_parameter_group.v16_parameter_group.name : aws_db_parameter_group.parameter_group.name
parameter_group_name = aws_db_parameter_group.v16_parameter_group.name
backup_retention_period = 7
iops = local.db_name == "ab2d-east-prod" ? "20000" : "5000"
apply_immediately = true
Expand Down

0 comments on commit 78c7894

Please sign in to comment.