From a3bd03af5ee25033e55e39592b940fa74c97d707 Mon Sep 17 00:00:00 2001 From: githubjianli <51385385+githubjianli@users.noreply.github.com> Date: Wed, 15 Feb 2023 10:23:01 -0800 Subject: [PATCH] Hotfix for v2.0.2 RDS upgrade (#224) * Update db.tf * Update variables.tf * Update CHANGELOG.md * Update db.tf --- CHANGELOG.md | 4 ++++ db.tf | 18 ++++++++++++++++++ variables.tf | 12 ++++++++++++ 3 files changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c26cd07..7979de9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [2.0.2-rds-upgrade] - 2023-01-15 +### Changed +- Upgrade apiary RDS version from `aurora5.6` to `aurora-mysql5.7` + ## [2.0.2] - 2019-06-06 ### Added diff --git a/db.tf b/db.tf index 1f2ac48..66cbf85 100644 --- a/db.tf +++ b/db.tf @@ -54,9 +54,25 @@ resource "random_string" "db_master_password" { special = false } +resource "aws_rds_cluster_parameter_group" "apiary_rds_param_group" { + name = "${local.instance_alias}-param-group" + family = "${var.rds_family}" # Needs to be kept in sync with aws_rds_cluster.apiary_cluster.engine and version + description = "Apiary-specific Aurora parameters" + tags = merge(map("Name", "${local.instance_alias}-param-group"), "${var.apiary_tags}") + + parameter { + name = "max_allowed_packet" + value = "${var.rds_max_allowed_packet}" + } + lifecycle { + create_before_destroy = true + } +} + resource "aws_rds_cluster" "apiary_cluster" { count = "${ var.external_database_host == "" ? 1 : 0 }" cluster_identifier = "${local.instance_alias}-cluster" + engine = "${var.rds_engine}" database_name = "${var.apiary_database_name}" master_username = "${var.db_master_username}" master_password = "${random_string.db_master_password.result}" @@ -68,6 +84,7 @@ resource "aws_rds_cluster" "apiary_cluster" { tags = "${var.apiary_tags}" final_snapshot_identifier = "${local.instance_alias}-cluster-final-${random_id.snapshot_id.hex}" iam_database_authentication_enabled = true + db_cluster_parameter_group_name = "${aws_rds_cluster_parameter_group.apiary_rds_param_group.name}" apply_immediately = "${var.db_apply_immediately}" lifecycle { @@ -79,6 +96,7 @@ resource "aws_rds_cluster_instance" "apiary_cluster_instance" { count = "${ var.external_database_host == "" ? var.db_instance_count : 0 }" identifier = "${local.instance_alias}-instance-${count.index}" cluster_identifier = "${aws_rds_cluster.apiary_cluster.id}" + engine = "${var.rds_engine}" instance_class = "${var.db_instance_class}" db_subnet_group_name = "${aws_db_subnet_group.apiarydbsg.name}" publicly_accessible = false diff --git a/variables.tf b/variables.tf index 4a11150..b600f02 100644 --- a/variables.tf +++ b/variables.tf @@ -344,3 +344,15 @@ variable "s3_lifecycle_policy_transition_period" { type = "string" default = "30" } + +variable "rds_family" { + description = "RDS family" + type = "string" + default = "aurora-mysql5.7" +} + +variable "rds_engine" { + description = "RDS engine version" + type = "string" + default = "aurora-mysql" +}