|
| 1 | +# Upgrade from v5.x to v6.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 | +With RDS now supporting the integration with SecretsManager to manage the master user password, the ability to generate a random password has been removed from this module. This is the preferred and strongly recommended route to mange the password since it keeps the password out of the Terraform state and allows for the password to be rotated automatically. |
| 10 | + |
| 11 | +## Variable and output changes |
| 12 | + |
| 13 | +1. Removed variables: |
| 14 | + |
| 15 | + - `create_random_password` -> support for random password generation has been removed |
| 16 | + - `random_password_length` -> support for random password generation has been removed |
| 17 | + |
| 18 | +2. Renamed variables: |
| 19 | + |
| 20 | + - None |
| 21 | + |
| 22 | +3. Added variables: |
| 23 | + |
| 24 | + - `manage_master_user_password` |
| 25 | + - `master_user_secret_kms_key_id` |
| 26 | + |
| 27 | +4. Removed outputs: |
| 28 | + |
| 29 | + - `db_instance_password` -> support for random password generation has been removed |
| 30 | + |
| 31 | + |
| 32 | +5. Renamed outputs: |
| 33 | + |
| 34 | + - `db_instance_id` -> `db_instance_identifier` |
| 35 | + |
| 36 | +6. Added outputs: |
| 37 | + |
| 38 | + - None |
| 39 | + |
| 40 | + |
| 41 | +## Upgrade Migrations |
| 42 | + |
| 43 | +### Before 5.x Example |
| 44 | + |
| 45 | +```hcl |
| 46 | +module "rds" { |
| 47 | + source = "terraform-aws-modules/rds/aws" |
| 48 | + version = "~> 5.0" |
| 49 | +
|
| 50 | + # Only the affected attributes are shown |
| 51 | + create_db_instance = true |
| 52 | +
|
| 53 | + create_random_password = true |
| 54 | + random_password_length = 16 |
| 55 | +
|
| 56 | + tags = { |
| 57 | + Environment = "dev" |
| 58 | + Terraform = "true" |
| 59 | + } |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +### After 6.x Example |
| 64 | + |
| 65 | +```hcl |
| 66 | +module "rds" { |
| 67 | + source = "terraform-aws-modules/rds/aws" |
| 68 | + version = "~> 6.0" |
| 69 | +
|
| 70 | + create_db_instance = true |
| 71 | +
|
| 72 | + manage_master_user_password = true |
| 73 | +
|
| 74 | + tags = { |
| 75 | + Environment = "dev" |
| 76 | + Terraform = "true" |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +### Retaining use of random password |
| 82 | + |
| 83 | +The following example demonstrates the changes that users can elect to make to avoid any potential disruptions when upgrading if electing not to use RDS password management with SecretsManager `manage_master_user_password` when previously using `create_random_password`. |
| 84 | + |
| 85 | +In this example, the `random_password` resource is added alongside the existing module to preserve the existing password. |
| 86 | + |
| 87 | +```hcl |
| 88 | +resource "random_password" "master_password" { |
| 89 | + length = 16 |
| 90 | + special = false |
| 91 | +} |
| 92 | +
|
| 93 | +module "rds" { |
| 94 | + source = "terraform-aws-modules/rds/aws" |
| 95 | + version = "~> 5.0" |
| 96 | +
|
| 97 | + # Only the affected attributes are shown |
| 98 | + create_db_instance = true |
| 99 | +
|
| 100 | + manage_master_user_password = false |
| 101 | +
|
| 102 | + password = random_password.master_password.result |
| 103 | +
|
| 104 | + tags = { |
| 105 | + Environment = "dev" |
| 106 | + Terraform = "true" |
| 107 | + } |
| 108 | +} |
| 109 | +``` |
| 110 | + |
| 111 | +A state move must be done to preserve the previously used random password. Example: |
| 112 | + |
| 113 | +``` |
| 114 | +terraform state mv 'module.rds.random_password.master_password[0]' random_password.master_password |
| 115 | +``` |
0 commit comments