Skip to content

Commit 2bf4622

Browse files
authored
feat!: Upgrade AWS provider and min required Terraform version to 6.18 and 1.11 respectively (#525)
1 parent 25b5c33 commit 2bf4622

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1501
-1446
lines changed

README.md

Lines changed: 119 additions & 166 deletions
Large diffs are not rendered by default.

docs/UPGRADE-10.0.md

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
# Upgrade from v9.x to v10.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+
- Terraform `v1.11` is now minimum supported version to support write-only (`wo_*`) attributes.
9+
- AWS provider `v6.18` is now minimum supported version
10+
- The underlying `aws_security_group_rule` resources has been replaced with `aws_vpc_security_group_ingress_rule` and `aws_vpc_security_group_egress_rule` to allow for more flexibility in defining security group rules.
11+
- `master_password` is no longer supported and only the write-only equivalent is supported (`master_password_wo` and `master_password_wo_version`) ([#513](https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/pull/513))
12+
- `security_group_rules` has been split into `security_group_ingress_rules` and `security_group_egress_rules` to better match the AWS API and allow for more flexibility in defining security group rules
13+
14+
## Additional changes
15+
16+
### Added
17+
18+
- Support for `region` argument to specify the AWS region for the resources created if different from the provider region.
19+
20+
### Modified
21+
22+
- Variable definitions now contain detailed object types in place of the previously used `any` type
23+
- `copy_tags_to_snapshot` default value is now `true` ([#521](https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/issues/521))
24+
- `db_cluster_parameter_group_parameters` was previously of type `list(map(...))`, now of type `map(object(...))`with `name` being optional and defaulting to the map key if not provided
25+
- `preferred_maintenance_window` and `preferred_backup_window` default values are now `null` ([#524](https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/pull/524))
26+
27+
### Removed
28+
29+
- None
30+
31+
### Variable and output changes
32+
33+
1. Removed variables:
34+
35+
- `auto_minor_version_upgrade` -> still available within the `instances` variable definition
36+
- `ca_cert_identifier` -> available within the `instances` variable definition
37+
- `monitoring_interval` -> still available within the `instances` variable definition
38+
- `performance_insights_enabled` -> still available within the `instances` variable definition
39+
- `performance_insights_kms_key_id` -> still available within the `instances` variable definition
40+
- `performance_insights_retention_period` -> still available within the `instances` variable definition
41+
- `iam_role_managed_policy_arns` -> deprecated argument on `aws_iam_role` resource
42+
- `iam_role_force_detach_policies` -> hardcode to `true`
43+
44+
2. Renamed variables:
45+
46+
- `instance_class` -> `cluster_instance_class`
47+
- `db_cluster_db_instance_parameter_group_name` -> `cluster_db_instance_parameter_group_name`
48+
- `role_associations` was previously `iam_roles`
49+
- `master_password` replaced with `master_password_wo` and `master_password_wo_version`
50+
- The variables for DB shard group have been nested under a single, top-level `shard_group` variable:
51+
- `create_shard_group` removed - set `shard_group` to `null` to disable or provide an object to enable
52+
- `compute_redundancy` -> `shard_group.compute_redundancy`
53+
- `db_shard_group_identifier` -> `shard_group.identifier`
54+
- `max_acu` -> `shard_group.max_acu`
55+
- `min_acu` -> `shard_group.min_acu`
56+
- `publicly_accessible` -> `shard_group.publicly_accessible`
57+
- `shard_group_tags` -> `shard_group.tags`
58+
- `shard_group_timeouts` -> `shard_group.timeouts`
59+
- The variables for the cluster activity stream have been nested under a single, top-level `cluster_activity_stream` variable:
60+
- `create_db_cluster_activity_stream` removed - set `cluster_activity_stream` to `null` to disable or provide an object to enable
61+
- `db_cluster_activity_stream_mode` -> `cluster_activity_stream.mode`
62+
- `db_cluster_activity_stream_kms_key_id` -> `cluster_activity_stream.kms_key_id`
63+
- `engine_native_audit_fields_included` -> `cluster_activity_stream.include_audit_fields`
64+
- The variables for the cluster parameter group have been nested under a single, top-level `cluster_parameter_group` variable:
65+
- `create_db_cluster_parameter_group` removed - set `cluster_parameter_group` to `null` to disable or provide an object to enable
66+
- `db_cluster_parameter_group_name` -> `cluster_parameter_group.name`
67+
- `db_cluster_parameter_group_use_name_prefix` -> `cluster_parameter_group.use_name_prefix`
68+
- `db_cluster_parameter_group_description` -> `cluster_parameter_group.description`
69+
- `db_cluster_parameter_group_family` -> `cluster_parameter_group.family`
70+
- `db_cluster_parameter_group_parameters` -> `cluster_parameter_group.parameters`
71+
- The variables for the instance parameter group have been nested under a single, top-level `db_parameter_group` variable:
72+
- `create_db_parameter_group` removed - set `db_parameter_group` to `null` to disable or provide an object to enable
73+
- `db_parameter_group_name` -> `db_parameter_group.name`
74+
- A variable `cluster_parameter_group_name` has been retained for when users want to provide an existing cluster parameter group name.
75+
- `db_parameter_group_use_name_prefix` -> `db_parameter_group.use_name_prefix`
76+
- `db_parameter_group_description` -> `db_parameter_group.description`
77+
- `db_parameter_group_family` -> `db_parameter_group.family`
78+
- `db_parameter_group_parameters` -> `db_parameter_group.parameters`
79+
80+
3. Added variables:
81+
82+
- `region`
83+
84+
4. Removed outputs:
85+
86+
- None
87+
88+
5. Renamed outputs:
89+
90+
- None
91+
92+
6. Added outputs:
93+
94+
- None
95+
96+
## Upgrade Migrations
97+
98+
### Before 9.x Example
99+
100+
```hcl
101+
module "cluster" {
102+
source = "terraform-aws-modules/rds-aurora/aws"
103+
version = "~> 9.0"
104+
105+
# Only the affected attributes are shown
106+
instance_class = "db.r8g.large"
107+
monitoring_interval = 60
108+
109+
security_group_rules = {
110+
vpc_ingress = {
111+
cidr_blocks = module.vpc.private_subnets_cidr_blocks
112+
}
113+
}
114+
115+
master_password = random_password.master.result
116+
117+
# For limitless databases
118+
create_shard_group = true
119+
compute_redundancy = 0
120+
db_shard_group_identifier = "example"
121+
max_acu = 16
122+
123+
create_db_cluster_parameter_group = true
124+
db_cluster_parameter_group_name = "example"
125+
db_cluster_parameter_group_family = "aurora-postgresql16"
126+
db_cluster_parameter_group_description = "Example cluster parameter group"
127+
db_cluster_parameter_group_parameters = [
128+
{
129+
name = "log_min_duration_statement"
130+
value = 4000
131+
apply_method = "immediate"
132+
}, {
133+
name = "rds.force_ssl"
134+
value = 1
135+
apply_method = "immediate"
136+
}
137+
]
138+
139+
create_db_parameter_group = true
140+
db_parameter_group_name = "example"
141+
db_parameter_group_family = "aurora-mysql8.0"
142+
db_parameter_group_description = "Example DB parameter group"
143+
db_parameter_group_parameters = [
144+
{
145+
name = "connect_timeout"
146+
value = 60
147+
apply_method = "immediate"
148+
},
149+
]
150+
151+
create_db_cluster_activity_stream = true
152+
db_cluster_activity_stream_kms_key_id = module.kms.key_id
153+
db_cluster_activity_stream_mode = "async"
154+
155+
iam_roles = {
156+
s3_import = {
157+
role_arn = aws_iam_role.s3_import.arn
158+
feature_name = "s3Import"
159+
}
160+
}
161+
162+
tags = {
163+
Environment = "dev"
164+
Terraform = "true"
165+
}
166+
}
167+
```
168+
169+
### After 10.x Example
170+
171+
```hcl
172+
module "cluster" {
173+
source = "terraform-aws-modules/rds-aurora/aws"
174+
version = "~> 10.0"
175+
176+
# Only the affected attributes are shown
177+
cluster_instance_class = "db.r8g.large"
178+
cluster_monitoring_interval = 60
179+
180+
security_group_ingress_rules = {
181+
private-az1 = {
182+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 0)
183+
}
184+
private-az2 = {
185+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 1)
186+
}
187+
private-az3 = {
188+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 2)
189+
}
190+
}
191+
192+
master_password_wo = random_password.master.result
193+
master_password_wo_version = 1
194+
195+
# For limitless databases
196+
shard_group = {
197+
compute_redundancy = 0
198+
identifier = "example"
199+
max_acu = 16
200+
}
201+
202+
cluster_parameter_group = {
203+
name = "example"
204+
family = "aurora-postgresql16"
205+
description = "Example cluster parameter group"
206+
parameters = [
207+
{
208+
name = "log_min_duration_statement"
209+
value = 4000
210+
apply_method = "immediate"
211+
}, {
212+
name = "rds.force_ssl"
213+
value = 1
214+
apply_method = "immediate"
215+
}
216+
]
217+
}
218+
219+
db_parameter_group = {
220+
name = "example"
221+
family = "aurora-mysql8.0"
222+
description = "Example DB parameter group"
223+
parameters = [
224+
{
225+
name = "connect_timeout"
226+
value = 60
227+
apply_method = "immediate"
228+
},
229+
]
230+
}
231+
232+
cluster_activity_stream = {
233+
kms_key_id = module.kms.key_id
234+
mode = "async"
235+
}
236+
237+
role_associations = {
238+
s3Import = {
239+
role_arn = aws_iam_role.s3_import.arn
240+
# feature_name = "s3Import" # same as setting value to key
241+
}
242+
}
243+
244+
tags = {
245+
Environment = "dev"
246+
Terraform = "true"
247+
}
248+
}
249+
```
250+
251+
### State Changes
252+
253+
Due to the change from `aws_security_group_rule` to `aws_vpc_security_group_ingress_rule` and `aws_vpc_security_group_egress_rule`, the following reference state changes are required to maintain the current security group rules. (Note: these are different resource types so they cannot be moved with `terraform mv ...`)
254+
255+
```sh
256+
terraform state rm 'module.aurora.aws_security_group_rule.this["vpc_ingress"]'
257+
terraform state import 'module.aurora.aws_vpc_security_group_ingress_rule.this["private-az1"]' 'sg-xxx'
258+
terraform state import 'module.aurora.aws_vpc_security_group_ingress_rule.this["private-az2"]' 'sg-xxx'
259+
terraform state import 'module.aurora.aws_vpc_security_group_ingress_rule.this["private-az3"]' 'sg-xxx'
260+
```

examples/autoscaling/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ Note that this example may create resources which cost money. Run `terraform des
1919

2020
| Name | Version |
2121
|------|---------|
22-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.89 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.11 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.18 |
2424

2525
## Providers
2626

2727
| Name | Version |
2828
|------|---------|
29-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.89 |
29+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.18 |
3030

3131
## Modules
3232

3333
| Name | Source | Version |
3434
|------|--------|---------|
3535
| <a name="module_aurora"></a> [aurora](#module\_aurora) | ../../ | n/a |
3636
| <a name="module_disabled_aurora"></a> [disabled\_aurora](#module\_disabled\_aurora) | ../../ | n/a |
37-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
37+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |
3838

3939
## Resources
4040

examples/autoscaling/main.tf

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ provider "aws" {
22
region = local.region
33
}
44

5-
data "aws_availability_zones" "available" {}
5+
data "aws_availability_zones" "available" {
6+
# Exclude local zones
7+
filter {
8+
name = "opt-in-status"
9+
values = ["opt-in-not-required"]
10+
}
11+
}
612

713
locals {
814
name = "ex-${basename(path.cwd)}"
@@ -25,26 +31,32 @@ locals {
2531
module "aurora" {
2632
source = "../../"
2733

28-
name = local.name
29-
engine = "aurora-postgresql"
30-
engine_version = "14.5"
31-
instance_class = "db.r6g.large"
32-
instances = { 1 = {} }
33-
master_username = "root"
34+
name = local.name
35+
engine = "aurora-postgresql"
36+
engine_version = "17.5"
37+
cluster_instance_class = "db.r8g.large"
38+
instances = { 1 = {} }
39+
master_username = "root"
3440

3541
vpc_id = module.vpc.vpc_id
3642
db_subnet_group_name = module.vpc.database_subnet_group_name
37-
security_group_rules = {
38-
vpc_ingress = {
39-
cidr_blocks = module.vpc.private_subnets_cidr_blocks
43+
security_group_ingress_rules = {
44+
private-az1 = {
45+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 0)
46+
}
47+
private-az2 = {
48+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 1)
49+
}
50+
private-az3 = {
51+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 2)
4052
}
4153
}
4254

4355
autoscaling_enabled = true
4456
autoscaling_min_capacity = 1
4557
autoscaling_max_capacity = 5
4658

47-
monitoring_interval = 60
59+
cluster_monitoring_interval = 60
4860
iam_role_name = "${local.name}-monitor"
4961
iam_role_use_name_prefix = true
5062
iam_role_description = "${local.name} RDS enhanced monitoring IAM role"
@@ -71,7 +83,7 @@ module "disabled_aurora" {
7183

7284
module "vpc" {
7385
source = "terraform-aws-modules/vpc/aws"
74-
version = "~> 5.0"
86+
version = "~> 6.0"
7587

7688
name = local.name
7789
cidr = local.vpc_cidr

examples/autoscaling/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.0"
2+
required_version = ">= 1.11"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.89"
7+
version = ">= 6.18"
88
}
99
}
1010
}

examples/dsql/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Note that this example may create resources which cost money. Run `terraform des
1919

2020
| Name | Version |
2121
|------|---------|
22-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.100 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.11 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.18 |
2424

2525
## Providers
2626

0 commit comments

Comments
 (0)