Skip to content

Commit 8b2a6c4

Browse files
committed
chore: Add Upgrade guide and validate examples
1 parent 9ac6703 commit 8b2a6c4

File tree

4 files changed

+126
-14
lines changed

4 files changed

+126
-14
lines changed

UPGRADE-7.0.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Upgrade from v6.x to v7.x
2+
3+
If you have any questions regarding this upgrade process, please consult the `examples` directory.
4+
If you find a bug, please open an issue with supporting configuration to reproduce.
5+
6+
## List of backwards incompatible changes
7+
8+
- The default value for `create_db_subnet_group` has changed from `true` to `false` - typically, a common/shared DB subnet group is utilized since there are no real tangible benefits to creating a new one for each DB cluster
9+
- `allowed_security_groups`, `allowed_cidr_blocks`, and `security_group_egress_rules` have been removed and replaced with a more generic `security_group_rules` variable which supports both ingress and egress rules to/from all supported resources/destinations (e.g. security groups, CIDR blocks, prefix lists, etc.)
10+
- Minimum supported Terraform version is no 1.0
11+
12+
### Variable and output changes
13+
14+
1. Removed variables:
15+
16+
- `allowed_security_groups` replaced by `security_group_rules`
17+
- `allowed_cidr_blocks` replaced by `security_group_rules`
18+
- `security_group_egress_rules` replaced by `security_group_rules`
19+
20+
2. Renamed variables:
21+
22+
- None
23+
24+
3. Added variables:
25+
26+
- `security_group_rules`
27+
28+
4. Removed outputs:
29+
30+
- None
31+
32+
5. Renamed outputs:
33+
34+
- None
35+
36+
6. Added outputs:
37+
38+
- None
39+
40+
## Upgrade Migrations
41+
42+
### Before 6.x Example
43+
44+
```hcl
45+
module "cluster_before" {
46+
source = "terraform-aws-modules/rds-aurora/aws"
47+
version = "~> 6.0"
48+
49+
# Only the affected attributes are shown
50+
51+
create_db_subnet_group = false
52+
db_subnet_group_name = module.vpc.database_subnet_group_name
53+
54+
create_security_group = true
55+
allowed_security_groups = ["sg-12345678"]
56+
allowed_cidr_blocks = ["10.20.0.0/20"]
57+
58+
tags = {
59+
Environment = "dev"
60+
Terraform = "true"
61+
}
62+
}
63+
```
64+
65+
### After 7.x Example
66+
67+
```hcl
68+
module "cluster_after" {
69+
source = "terraform-aws-modules/rds-aurora/aws"
70+
version = "~> 7.0"
71+
72+
# Only the affected attributes are shown
73+
74+
db_subnet_group_name = module.vpc.database_subnet_group_name
75+
76+
security_group_rules = {
77+
cidr_ingress_ex = {
78+
cidr_blocks = ["10.20.0.0/20"]
79+
}
80+
security_group_ingress_ex = {
81+
source_security_group_id = "sg-12345678"
82+
}
83+
}
84+
85+
tags = {
86+
Environment = "dev"
87+
Terraform = "true"
88+
}
89+
}
90+
```
91+
92+
### State Changes
93+
94+
- None
95+
96+
#### Security Group Rule(s) Migration
97+
98+
To upgrade to v7.x, you will need to migrate your security group rules to the new `security_group_rules` variable and data structure. There are three potential avenues to accomplish this:
99+
100+
1. Perform Terraform state moves `terraform state mv ...`. This has the downside of requiring manual intervention via the Terraform CLI but is still one possiblity.
101+
2. Applying the changes as they are which will result in the old security group ruls being removed and the new rules being added. This has the downside of causing a brief interruption in service which may or may not be tolerable; this is left up to users to decided.
102+
3. In addition to option 2, users can create a new, temporary security group that contains all of the same network access (or more) as the current v6.x security group. Before upgrading your cluster, add this security group to the cluster via the `vpc_security_group_ids` argument which "shadows" the same level of network access while upgrading. Once this security group has been added, you can now safely upgrade from v6.x to v7.x without any network disruption. Once the upgrade is complete, you can remove the temporary security group from the cluster and delete.

examples/mysql/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module "aurora" {
6161

6262
create_db_cluster_parameter_group = true
6363
db_cluster_parameter_group_name = local.name
64-
db_cluster_parameter_group_family = "aurora-mysql5.7"
64+
db_cluster_parameter_group_family = "aurora-mysql8.0"
6565
db_cluster_parameter_group_description = "${local.name} example cluster parameter group"
6666
db_cluster_parameter_group_parameters = [
6767
{
@@ -105,7 +105,7 @@ module "aurora" {
105105

106106
create_db_parameter_group = true
107107
db_parameter_group_name = local.name
108-
db_parameter_group_family = "aurora-mysql5.7"
108+
db_parameter_group_family = "aurora-mysql8.0"
109109
db_parameter_group_description = "${local.name} example DB parameter group"
110110
db_parameter_group_parameters = [
111111
{
@@ -153,7 +153,8 @@ module "aurora" {
153153
################################################################################
154154

155155
resource "random_password" "master" {
156-
length = 10
156+
length = 10
157+
special = false
157158
}
158159

159160
module "vpc" {

examples/postgresql/main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module "aurora" {
8080

8181
create_db_cluster_parameter_group = true
8282
db_cluster_parameter_group_name = local.name
83-
db_cluster_parameter_group_family = "aurora-postgresql11"
83+
db_cluster_parameter_group_family = "aurora-postgresql14"
8484
db_cluster_parameter_group_description = "${local.name} example cluster parameter group"
8585
db_cluster_parameter_group_parameters = [
8686
{
@@ -96,7 +96,7 @@ module "aurora" {
9696

9797
create_db_parameter_group = true
9898
db_parameter_group_name = local.name
99-
db_parameter_group_family = "aurora-postgresql11"
99+
db_parameter_group_family = "aurora-postgresql14"
100100
db_parameter_group_description = "${local.name} example DB parameter group"
101101
db_parameter_group_parameters = [
102102
{
@@ -116,7 +116,8 @@ module "aurora" {
116116
################################################################################
117117

118118
resource "random_password" "master" {
119-
length = 10
119+
length = 10
120+
special = false
120121
}
121122

122123
module "vpc" {

examples/serverless/main.tf

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ module "aurora_postgresql" {
3030
engine_mode = "serverless"
3131
storage_encrypted = true
3232

33-
vpc_id = module.vpc.vpc_id
34-
subnets = module.vpc.database_subnets
33+
vpc_id = module.vpc.vpc_id
34+
db_subnet_group_name = module.vpc.database_subnet_group_name
3535
security_group_rules = {
3636
vpc_ingress = {
3737
cidr_blocks = module.vpc.private_subnets_cidr_blocks
@@ -52,6 +52,8 @@ module "aurora_postgresql" {
5252
seconds_until_auto_pause = 300
5353
timeout_action = "ForceApplyCapacityChange"
5454
}
55+
56+
tags = local.tags
5557
}
5658

5759
################################################################################
@@ -66,8 +68,8 @@ module "aurora_mysql" {
6668
engine_mode = "serverless"
6769
storage_encrypted = true
6870

69-
vpc_id = module.vpc.vpc_id
70-
subnets = module.vpc.database_subnets
71+
vpc_id = module.vpc.vpc_id
72+
db_subnet_group_name = module.vpc.database_subnet_group_name
7173
security_group_rules = {
7274
vpc_ingress = {
7375
cidr_blocks = module.vpc.private_subnets_cidr_blocks
@@ -88,6 +90,8 @@ module "aurora_mysql" {
8890
seconds_until_auto_pause = 300
8991
timeout_action = "ForceApplyCapacityChange"
9092
}
93+
94+
tags = local.tags
9195
}
9296

9397
################################################################################
@@ -103,8 +107,8 @@ module "aurora_mysql_v2" {
103107
engine_version = "8.0"
104108
storage_encrypted = true
105109

106-
vpc_id = module.vpc.vpc_id
107-
subnets = module.vpc.database_subnets
110+
vpc_id = module.vpc.vpc_id
111+
db_subnet_group_name = module.vpc.database_subnet_group_name
108112
security_group_rules = {
109113
vpc_ingress = {
110114
cidr_blocks = module.vpc.private_subnets_cidr_blocks
@@ -126,6 +130,8 @@ module "aurora_mysql_v2" {
126130
one = {}
127131
two = {}
128132
}
133+
134+
tags = local.tags
129135
}
130136

131137
################################################################################
@@ -146,8 +152,8 @@ module "aurora_postgresql_v2" {
146152
engine_version = data.aws_rds_engine_version.postgresql.version
147153
storage_encrypted = true
148154

149-
vpc_id = module.vpc.vpc_id
150-
subnets = module.vpc.database_subnets
155+
vpc_id = module.vpc.vpc_id
156+
db_subnet_group_name = module.vpc.database_subnet_group_name
151157
security_group_rules = {
152158
vpc_ingress = {
153159
cidr_blocks = module.vpc.private_subnets_cidr_blocks
@@ -169,6 +175,8 @@ module "aurora_postgresql_v2" {
169175
one = {}
170176
two = {}
171177
}
178+
179+
tags = local.tags
172180
}
173181

174182
################################################################################

0 commit comments

Comments
 (0)