Skip to content

Commit

Permalink
PLT-724 Apply api-rds service to ab2d dev (#140)
Browse files Browse the repository at this point in the history
## 🎫 Ticket

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

## 🛠 Changes

Added dev environment to plan/apply action matrices

## ℹ️ Context

PLT-719 needs for us to update ab2d dev and test to Postgres 16, this is
attempting to make that change from the same location. for both .

<!-- 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

Validated locally with terraform plan; also verifying via terraform plan
github action
  • Loading branch information
ildesenesence authored Oct 31, 2024
1 parent e6153f4 commit efbc3f9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-rds-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
app: [ab2d]
env: [test]
env: [dev, test]
steps:
- uses: actions/checkout@v4
- uses: ./actions/setup-tfenv-terraform
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-rds-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
fail-fast: false
matrix:
app: [ab2d]
env: [test]
env: [dev, test]
steps:
- uses: actions/checkout@v4
- uses: ./actions/setup-tfenv-terraform
Expand Down
39 changes: 31 additions & 8 deletions terraform/services/api-rds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ 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 @@ -87,14 +107,23 @@ resource "aws_db_parameter_group" "parameter_group" {
value = "1200000"
apply_method = "immediate"
}
parameter {
name = "rds.logical_replication"
value = contains(["ab2d-dev", "ab2d-test"], local.db_name) ? "1" : "0"
apply_method = "pending-reboot"
}

lifecycle {
create_before_destroy = true
}
}

# Create database instance

resource "aws_db_instance" "api" {
allocated_storage = 500
engine = "postgres"
engine_version = 15.5
engine_version = local.postgres_ver
instance_class = "db.m6i.2xlarge"
identifier = local.db_name
storage_encrypted = true
Expand All @@ -111,7 +140,7 @@ resource "aws_db_instance" "api" {
iops = local.db_name == "ab2d-east-prod" ? "20000" : "5000"
apply_immediately = true
kms_key_id = data.aws_kms_alias.main_kms.target_key_arn
multi_az = local.db_name == "ab2d-east-prod" ? true : false
multi_az = local.db_name == "ab2d-east-prod"
vpc_security_group_ids = [aws_security_group.sg_database.id]
username = data.aws_secretsmanager_secret_version.database_user.secret_string
password = data.aws_secretsmanager_secret_version.database_password.secret_string
Expand All @@ -124,10 +153,4 @@ resource "aws_db_instance" "api" {
"cpm backup" = "Monthly"
})
)
lifecycle {
ignore_changes = [
engine_version,
parameter_group_name
]
}
}

0 comments on commit efbc3f9

Please sign in to comment.