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

[OSDEV-1514] Database. Upgrade the PostgreSQL version to 13 #479

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
4 changes: 2 additions & 2 deletions .github/workflows/deploy_to_aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ jobs:
uses: docker/build-push-action@v2
if: ${{ steps.get_env_name.outputs.lowercase == 'production' }}
with:
context: deployment/terraform/database_anonymizer_sheduled_task/docker
file: deployment/terraform/database_anonymizer_sheduled_task/docker/Dockerfile
context: deployment/terraform/database_anonymizer_scheduled_task/docker
file: deployment/terraform/database_anonymizer_scheduled_task/docker/Dockerfile
push: true
tags: ${{ vars.ECR_REGISTRY }}/${{ vars.IMAGE_NAME }}-database-anonymizer-${{ steps.get_env_name.outputs.lowercase }}:${{ env.GIT_COMMIT }}

Expand Down
8 changes: 4 additions & 4 deletions deployment/environments/terraform-development.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ bastion_ami = "ami-0bb3fad3c0286ebd5"
bastion_instance_type = "t3.nano"

rds_allocated_storage = "128"
rds_engine_version = "12"
rds_parameter_group_family = "postgres12"
rds_engine_version = "13"
rds_parameter_group_family = "postgres13"
rds_instance_type = "db.t3.micro"
rds_database_identifier = "opensupplyhub-enc-stg"
rds_database_name = "opensupplyhub"
rds_multi_az = false
rds_storage_encrypted = true
snapshot_identifier = ""
rds_deletion_protection = true
rds_allow_major_version_upgrade = true
rds_apply_immediately = true

app_ecs_desired_count = "1"
app_ecs_deployment_min_percent = "100"
Expand Down
4 changes: 2 additions & 2 deletions deployment/environments/terraform-preprod.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ bastion_ami = "ami-0bb3fad3c0286ebd5"
bastion_instance_type = "t3.nano"

rds_allocated_storage = "256"
rds_engine_version = "12"
rds_parameter_group_family = "postgres12"
rds_engine_version = "13"
rds_parameter_group_family = "postgres13"
mazursasha1990 marked this conversation as resolved.
Show resolved Hide resolved
rds_instance_type = "db.m6in.4xlarge"
rds_database_identifier = "opensupplyhub-enc-pp"
rds_database_name = "opensupplyhub"
Expand Down
6 changes: 4 additions & 2 deletions deployment/environments/terraform-production.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ bastion_ami = "ami-0bb3fad3c0286ebd5"
bastion_instance_type = "t3.nano"

rds_allocated_storage = "256"
rds_engine_version = "12"
rds_parameter_group_family = "postgres12"
rds_engine_version = "13"
rds_parameter_group_family = "postgres13"
rds_instance_type = "db.m6in.4xlarge"
rds_database_identifier = "opensupplyhub-enc-prd"
rds_database_name = "opensupplyhub"
rds_multi_az = false
rds_storage_encrypted = true
rds_allow_major_version_upgrade = true
rds_apply_immediately = true

app_ecs_desired_count = "10"
app_ecs_deployment_min_percent = "100"
Expand Down
6 changes: 4 additions & 2 deletions deployment/environments/terraform-staging.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ bastion_ami = "ami-0bb3fad3c0286ebd5"
bastion_instance_type = "t3.nano"

rds_allocated_storage = "128"
rds_engine_version = "12"
rds_parameter_group_family = "postgres12"
rds_engine_version = "13"
rds_parameter_group_family = "postgres13"
rds_instance_type = "db.t3.large"
rds_database_identifier = "opensupplyhub-enc-stg"
rds_database_name = "opensupplyhub"
rds_multi_az = false
rds_storage_encrypted = true
rds_allow_major_version_upgrade = true
rds_apply_immediately = true

app_ecs_desired_count = "4"
app_ecs_deployment_min_percent = "100"
Expand Down
6 changes: 4 additions & 2 deletions deployment/environments/terraform-test.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ bastion_ami = "ami-0bb3fad3c0286ebd5"
bastion_instance_type = "t3.nano"

rds_allocated_storage = "256"
rds_engine_version = "12"
rds_parameter_group_family = "postgres12"
rds_engine_version = "13"
rds_parameter_group_family = "postgres13"
rds_instance_type = "db.t3.xlarge"
rds_database_identifier = "opensupplyhub-enc-tst"
rds_database_name = "opensupplyhub"
rds_multi_az = false
rds_storage_encrypted = true
rds_allow_major_version_upgrade = true
rds_apply_immediately = true

anonymized_database_instance_type = "db.t3.2xlarge"
anonymized_database_identifier = "database-anonymizer"
Expand Down
2 changes: 1 addition & 1 deletion deployment/terraform/anonymize_db_job.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "database_anonymizer" {
count = var.database_anonymizer_enabled == true ? 1 : 0

source = "./database_anonymizer_sheduled_task"
source = "./database_anonymizer_scheduled_task"

rds_database_identifier = var.rds_database_identifier
rds_database_name = var.rds_database_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM postgis/postgis:12-3.4-alpine
FROM postgis/postgis:13-3.4-alpine

WORKDIR /opt/

Expand Down
50 changes: 26 additions & 24 deletions deployment/terraform/database.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,32 @@ resource "aws_db_parameter_group" "default" {
}

module "database_enc" {
source = "github.com/opensupplyhub/terraform-aws-postgresql-rds?ref=3.0.3"

vpc_id = module.vpc.id
allocated_storage = var.rds_allocated_storage
engine_version = var.rds_engine_version
instance_type = var.rds_instance_type
storage_type = var.rds_storage_type
database_identifier = var.rds_database_identifier
database_name = var.rds_database_name
database_username = var.rds_database_username
database_password = var.rds_database_password
backup_retention_period = var.rds_backup_retention_period
backup_window = var.rds_backup_window
maintenance_window = var.rds_maintenance_window
auto_minor_version_upgrade = var.rds_auto_minor_version_upgrade
final_snapshot_identifier = join("-", [var.rds_final_snapshot_identifier, formatdate("YYYYMMDDhhmmss", timestamp())])
skip_final_snapshot = var.rds_skip_final_snapshot
copy_tags_to_snapshot = var.rds_copy_tags_to_snapshot
multi_availability_zone = var.rds_multi_az
storage_encrypted = var.rds_storage_encrypted
subnet_group = aws_db_subnet_group.default.name
parameter_group = aws_db_parameter_group.default.name
deletion_protection = var.rds_deletion_protection
snapshot_identifier = var.snapshot_identifier
source = "github.com/opensupplyhub/terraform-aws-postgresql-rds?ref=3.1.0"

vpc_id = module.vpc.id
allocated_storage = var.rds_allocated_storage
engine_version = var.rds_engine_version
instance_type = var.rds_instance_type
storage_type = var.rds_storage_type
database_identifier = var.rds_database_identifier
database_name = var.rds_database_name
database_username = var.rds_database_username
database_password = var.rds_database_password
backup_retention_period = var.rds_backup_retention_period
backup_window = var.rds_backup_window
maintenance_window = var.rds_maintenance_window
auto_minor_version_upgrade = var.rds_auto_minor_version_upgrade
allow_major_version_upgrade = var.rds_allow_major_version_upgrade
apply_immediately = var.rds_apply_immediately
vladsha-dev marked this conversation as resolved.
Show resolved Hide resolved
final_snapshot_identifier = join("-", [var.rds_final_snapshot_identifier, formatdate("YYYYMMDDhhmmss", timestamp())])
skip_final_snapshot = var.rds_skip_final_snapshot
copy_tags_to_snapshot = var.rds_copy_tags_to_snapshot
multi_availability_zone = var.rds_multi_az
storage_encrypted = var.rds_storage_encrypted
subnet_group = aws_db_subnet_group.default.name
parameter_group = aws_db_parameter_group.default.name
deletion_protection = var.rds_deletion_protection
snapshot_identifier = var.snapshot_identifier

alarm_cpu_threshold = var.rds_cpu_threshold_percent
alarm_disk_queue_threshold = var.rds_disk_queue_threshold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@
)

db = pg8000.native.Connection(**connection_information)
# cur = db.cursor()
# cur.execute(open("anonymize_script.sql", "r").read())
# cur.commit()
db.run(open("anonymize_script.sql", "r").read())
print('Database anonymized successfully!')

Expand Down
16 changes: 14 additions & 2 deletions deployment/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ variable "rds_allocated_storage" {
}

variable "rds_engine_version" {
default = "12.4"
default = "13"
}

variable "rds_parameter_group_family" {
default = "postgres12"
default = "postgres13"
}

variable "rds_instance_type" {
Expand Down Expand Up @@ -114,6 +114,18 @@ variable "rds_auto_minor_version_upgrade" {
default = true
}

variable "rds_allow_major_version_upgrade" {
default = false
type = bool
description = "Indicates that major PostgreSQL engine version upgrades are allowed."
}

variable "rds_apply_immediately" {
default = false
type = bool
description = "Specifies whether any database modifications are applied immediately, or during the next maintenance window."
}

variable "rds_final_snapshot_identifier" {
default = "osh-rds-snapshot"
}
Expand Down
6 changes: 4 additions & 2 deletions doc/release/RELEASE-NOTES-TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ Use the format below to document information about the new release.
* Release date: *Provide release date*

### Database changes
* *Describe high-level database changes.*

#### Migrations:
* *Describe migrations here.*

#### Scheme changes
* *Describe scheme changes here.*
#### Schema changes
* *Describe schema changes here.*

### Code/API changes
* *Describe code/API changes here.*
Expand Down
Loading
Loading