Skip to content

Commit

Permalink
Hotfix for v2.0.2 RDS upgrade (#224)
Browse files Browse the repository at this point in the history
* Update db.tf

* Update variables.tf

* Update CHANGELOG.md

* Update db.tf
  • Loading branch information
githubjianli authored Feb 15, 2023
1 parent 3f7cd47 commit a3bd03a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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 {
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit a3bd03a

Please sign in to comment.