Skip to content

Commit 9149ec1

Browse files
authored
feat!: Update default values for security posture improvement (#369)
BREAKING CHANGES: - Support for Terraform `<=v0.12.x` has been dropped; `v0.13.1` is now the minimum supported version - Terraform AWS provider minimum version is now `v4.0.0` in order to support the replacement of `var.name`(deprecated) for `var.db_name` - Separate RDS instance resource for MSSQL/SQLServer has been removed - all engines are supported under one resource - `storage_encrypted` is now set to `true` by default; was previously `false` - `create_random_password` is now set to `true` by default; was previously `false` - `create_db_subnet_group` is now set to `false` by default; was previously `true`; typically a shared DB subnet group will be used, most likely from the VPC module - `random_password_length` is now set to `16` by default, was previously `10` - Random provider minimum version supported is now `v3.1.0` - `final_snapshot_identifier` no longer coalesces `var.final_snapshot_identifier` and instead relies on `var.final_snapshot_identifier_prefix` with a random suffix to avoid name collisions
1 parent 87b20a2 commit 9149ec1

Some content is hidden

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

53 files changed

+496
-551
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.62.3
3+
rev: v1.64.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_validate

README.md

Lines changed: 42 additions & 43 deletions
Large diffs are not rendered by default.

UPGRADE-4.0.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Upgrade from v3.x to v4.x
2+
3+
If you have any questions regarding this upgrade process, please consult the [`examples/`](https://github.com/terraform-aws-modules/terraform-aws-rds/tree/master/examples) projects:
4+
5+
If you find a bug, please open an issue with supporting configuration to reproduce.
6+
7+
## List of backwards incompatible changes
8+
9+
- Support for Terraform `<=v0.12.x` has been dropped; `v0.13.1` is now the minimum supported version
10+
- Terraform AWS provider minimum version is now `v4.0.0` in order to support the replacement of `var.name`(deprecated) for `var.db_name`
11+
- Separate RDS instance resource for MSSQL/SQLServer has been removed - all engines are supported under one resource
12+
- `storage_encrypted` is now set to `true` by default; was previously `false`
13+
- `create_random_password` is now set to `true` by default; was previously `false`
14+
- `create_db_subnet_group` is now set to `false` by default; was previously `true`; typically a shared DB subnet group will be used, most likely from the VPC module
15+
- `random_password_length` is now set to `16` by default, was previously `10`
16+
- Random provider minimum version supported is now `v3.1.0`
17+
- `final_snapshot_identifier` no longer coalesces `var.final_snapshot_identifier` and instead relies on `var.final_snapshot_identifier_prefix` with a random suffix to avoid name collisions
18+
19+
## Additional changes
20+
21+
### Added
22+
23+
- `latest_restorable_time` added to ignored changes
24+
- `replica_mode` support added to DB instance
25+
26+
### Modified
27+
28+
- `username`, `password`, and `engine` are set to `null` when a `replicate_source_db` or `snapshot_identifier` is provided; these values are already provided in the respective source
29+
- `engine_version` is set to `null` when a value is provided for `replicate_source_db`
30+
- `db_subnet_group_name` has been updated to use full name when prefix is enabled
31+
- `Name` tag removed from instance resource; name is set via `identifier` and not through tags; users can add back into the tags they provide if desired
32+
- Outputs have been updated to use `try()` syntax; local variable usage has been removed within outputs
33+
- `engine`, `major_engine_version`, `family`, `password`, `db_subnet_group_name`,`db_subnet_group_description`,`parameter_group_name`,
34+
`parameter_group_description`, `option_group_name`, `option_group_description` is now set to `null` by default; was previously `""`
35+
- `timeouts` is now set to `{}` by default; was previously a copy+paste of default value used by provider. This is a no-op but will show up in plans as a diff
36+
37+
### Variable and output changes
38+
39+
1. Removed variables:
40+
41+
- `final_snapshot_identifier`
42+
43+
2. Renamed variables:
44+
45+
- `name` (deprecated) -> `db_name`
46+
47+
3. Added variables:
48+
49+
- `replica_mode`
50+
51+
4. Removed outputs:
52+
53+
- None
54+
55+
5. Renamed outputs:
56+
57+
- None
58+
59+
6. Added outputs:
60+
61+
- None
62+
63+
## Upgrade Migrations
64+
65+
The following examples demonstrate some of the changes that users can elect to make to avoid any potential disruptions when upgrading.
66+
67+
### Before 3.x Example
68+
69+
```hcl
70+
module "rds" {
71+
source = "terraform-aws-modules/rds/aws"
72+
version = "~> 3.0"
73+
74+
master_password = "MySuperStrongPassword!"
75+
76+
# Previously on read-replicas or restored from snapshot instances you needed to explicitly set these to null
77+
# These can now be safely removed and instead on the module to resolve these appropriately
78+
username = null
79+
password = null
80+
engine = null
81+
}
82+
```
83+
84+
### After 4.x Example
85+
86+
```hcl
87+
module "asg" {
88+
source = "terraform-aws-modules/rds/aws"
89+
version = "~> 4.0"
90+
91+
master_password = "MySuperStrongPassword!"
92+
# Set random password creation to false if providing your own password as input
93+
create_random_password = false
94+
95+
# If you did not have storage encrypted in `v3.x`, you can explicitly disable in `v4.x` to avoid disruption
96+
storage_encrypted = false
97+
}
98+
```
99+
100+
#### MSSQL/SQLServer
101+
102+
For MSSSQL/SQLServer, users will want to rename the resource in their Terraform state to align with the flattened DB instance resource module in v4.x:
103+
104+
```bash
105+
terraform state mv 'module.<module-name>.module.db_instance.aws_db_instance.this_mssql[0]' 'module.<module-name>.module.db_instance.aws_db_instance.this[0]'
106+
```
107+
108+
Where `<module-name>` is the name of your module definition.

examples/complete-mssql/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ 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) | >= 0.12.26 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.49 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
2424

2525
## Providers
2626

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

3131
## Modules
3232

3333
| Name | Source | Version |
3434
|------|--------|---------|
3535
| <a name="module_db"></a> [db](#module\_db) | ../../ | n/a |
3636
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | n/a |
37-
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4 |
38-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
37+
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
38+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |
3939

4040
## Resources
4141

examples/complete-mssql/main.tf

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ locals {
1717

1818
module "vpc" {
1919
source = "terraform-aws-modules/vpc/aws"
20-
version = "~> 2"
20+
version = "~> 3.0"
2121

2222
name = local.name
2323
cidr = "10.99.0.0/18"
@@ -34,7 +34,7 @@ module "vpc" {
3434

3535
module "security_group" {
3636
source = "terraform-aws-modules/security-group/aws"
37-
version = "~> 4"
37+
version = "~> 4.0"
3838

3939
name = local.name
4040
description = "Complete SqlServer example security group"
@@ -116,20 +116,16 @@ module "db" {
116116
identifier = local.name
117117

118118
engine = "sqlserver-ex"
119-
engine_version = "15.00.4073.23.v1"
119+
engine_version = "15.00.4153.1.v1"
120120
family = "sqlserver-ex-15.0" # DB parameter group
121121
major_engine_version = "15.00" # DB option group
122122
instance_class = "db.t3.large"
123123

124124
allocated_storage = 20
125125
max_allocated_storage = 100
126-
storage_encrypted = false
127126

128-
name = null
129-
username = "complete_mssql"
130-
create_random_password = true
131-
random_password_length = 12
132-
port = 1433
127+
username = "complete_mssql"
128+
port = 1433
133129

134130
domain = aws_directory_service_directory.demo.id
135131
domain_iam_role_name = aws_iam_role.rds_ad_auth.name
@@ -166,7 +162,6 @@ module "db_disabled" {
166162
identifier = "${local.name}-disabled"
167163

168164
create_db_instance = false
169-
create_db_subnet_group = false
170165
create_db_parameter_group = false
171166
create_db_option_group = false
172167
}

examples/complete-mssql/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 = ">= 0.12.26"
2+
required_version = ">= 0.13.1"
33

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

examples/complete-mysql/README.md

Lines changed: 4 additions & 4 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) | >= 0.12.26 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.49 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
2424

2525
## Providers
2626

@@ -33,8 +33,8 @@ No providers.
3333
| <a name="module_db"></a> [db](#module\_db) | ../../ | n/a |
3434
| <a name="module_db_default"></a> [db\_default](#module\_db\_default) | ../../ | n/a |
3535
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | n/a |
36-
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4 |
37-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
36+
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
37+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |
3838

3939
## Resources
4040

examples/complete-mysql/main.tf

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ locals {
1717

1818
module "vpc" {
1919
source = "terraform-aws-modules/vpc/aws"
20-
version = "~> 2"
20+
version = "~> 3.0"
2121

2222
name = local.name
2323
cidr = "10.99.0.0/18"
@@ -34,7 +34,7 @@ module "vpc" {
3434

3535
module "security_group" {
3636
source = "terraform-aws-modules/security-group/aws"
37-
version = "~> 4"
37+
version = "~> 4.0"
3838

3939
name = local.name
4040
description = "Complete MySQL example security group"
@@ -65,18 +65,16 @@ module "db" {
6565

6666
# All available versions: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.VersionMgmt
6767
engine = "mysql"
68-
engine_version = "8.0.20"
68+
engine_version = "8.0.27"
6969
family = "mysql8.0" # DB parameter group
7070
major_engine_version = "8.0" # DB option group
71-
instance_class = "db.t3.large"
71+
instance_class = "db.t3a.large"
7272

7373
allocated_storage = 20
7474
max_allocated_storage = 100
75-
storage_encrypted = false
7675

77-
name = "completeMysql"
76+
db_name = "completeMysql"
7877
username = "complete_mysql"
79-
password = "YourPwdShouldBeLongAndSecure!"
8078
port = 3306
8179

8280
multi_az = true
@@ -132,18 +130,16 @@ module "db_default" {
132130

133131
# All available versions: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.VersionMgmt
134132
engine = "mysql"
135-
engine_version = "8.0.20"
133+
engine_version = "8.0.27"
136134
family = "mysql8.0" # DB parameter group
137135
major_engine_version = "8.0" # DB option group
138-
instance_class = "db.t3.large"
136+
instance_class = "db.t3a.large"
139137

140138
allocated_storage = 20
141139

142-
name = "completeMysql"
143-
username = "complete_mysql"
144-
create_random_password = true
145-
random_password_length = 12
146-
port = 3306
140+
db_name = "completeMysql"
141+
username = "complete_mysql"
142+
port = 3306
147143

148144
subnet_ids = module.vpc.database_subnets
149145
vpc_security_group_ids = [module.security_group.security_group_id]
@@ -162,7 +158,6 @@ module "db_disabled" {
162158
identifier = "${local.name}-disabled"
163159

164160
create_db_instance = false
165-
create_db_subnet_group = false
166161
create_db_parameter_group = false
167162
create_db_option_group = false
168163
}

examples/complete-mysql/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 = ">= 0.12.26"
2+
required_version = ">= 0.13.1"
33

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

examples/complete-oracle/README.md

Lines changed: 4 additions & 4 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) | >= 0.12.26 |
23-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.49 |
22+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
23+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
2424

2525
## Providers
2626

@@ -32,8 +32,8 @@ No providers.
3232
|------|--------|---------|
3333
| <a name="module_db"></a> [db](#module\_db) | ../../ | n/a |
3434
| <a name="module_db_disabled"></a> [db\_disabled](#module\_db\_disabled) | ../../ | n/a |
35-
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4 |
36-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2 |
35+
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | terraform-aws-modules/security-group/aws | ~> 4.0 |
36+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |
3737

3838
## Resources
3939

examples/complete-oracle/main.tf

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ locals {
1717

1818
module "vpc" {
1919
source = "terraform-aws-modules/vpc/aws"
20-
version = "~> 2"
20+
version = "~> 3.0"
2121

2222
name = local.name
2323
cidr = "10.99.0.0/18"
@@ -34,7 +34,7 @@ module "vpc" {
3434

3535
module "security_group" {
3636
source = "terraform-aws-modules/security-group/aws"
37-
version = "~> 4"
37+
version = "~> 4.0"
3838

3939
name = local.name
4040
description = "Complete Oracle example security group"
@@ -64,22 +64,19 @@ module "db" {
6464
identifier = "demodb-oracle"
6565

6666
engine = "oracle-ee"
67-
engine_version = "12.1.0.2.v8"
68-
family = "oracle-ee-12.1" # DB parameter group
69-
major_engine_version = "12.1" # DB option group
67+
engine_version = "19.0.0.0.ru-2021-10.rur-2021-10.r1"
68+
family = "oracle-ee-19.0" # DB parameter group
69+
major_engine_version = "19.0" # DB option group
7070
instance_class = "db.t3.large"
7171
license_model = "bring-your-own-license"
7272

7373
allocated_storage = 20
7474
max_allocated_storage = 100
75-
storage_encrypted = false
7675

7776
# Make sure that database name is capitalized, otherwise RDS will try to recreate RDS instance every time
78-
name = "COMPLETEORACLE"
79-
username = "complete_oracle"
80-
create_random_password = true
81-
random_password_length = 12
82-
port = 1521
77+
db_name = "COMPLETEORACLE"
78+
username = "complete_oracle"
79+
port = 1521
8380

8481
multi_az = true
8582
subnet_ids = module.vpc.database_subnets
@@ -109,7 +106,6 @@ module "db_disabled" {
109106
identifier = "${local.name}-disabled"
110107

111108
create_db_instance = false
112-
create_db_subnet_group = false
113109
create_db_parameter_group = false
114110
create_db_option_group = false
115111
}

0 commit comments

Comments
 (0)