Skip to content

Commit 5daa5ca

Browse files
committed
chore: update migration steps
1 parent d05ed10 commit 5daa5ca

File tree

1 file changed

+54
-6
lines changed

1 file changed

+54
-6
lines changed

UPGRADE-6.0.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ If you find a bug, please open an issue with supporting configuration to reprodu
8282
- `additional_cluster_endpoints`
8383
- `cluster_role_associations`
8484

85-
## Upgrade State Migrations
85+
## Upgrade Migrations
8686

8787
### Before 5.x Example
8888

@@ -193,18 +193,66 @@ module "cluster_after" {
193193
}
194194
```
195195

196+
### State Changes
197+
196198
To migrate from the `v5.x` version to `v6.x` version example shown above, the following state move commands can be performed to maintain the current resources without modification:
197199

198200
```bash
199-
terraform state mv 'module.cluster_before.aws_rds_cluster_instance.this[0]' 'module.cluster_after.aws_rds_cluster_instance.this["0"]'
200-
# Note: this move will need to be made for each instance in the cluster, where `<n>` is the instance creation order and is mapped to its new `<key>` specified
201+
terraform state mv 'module.cluster_before.aws_rds_cluster_instance.this[0]' 'module.cluster_after.aws_rds_cluster_instance.this["1"]'
202+
# Note: this move will need to be made for each instance in the cluster, where `<index>` is the instance creation index/position and is mapped to its new `<key>` specified
201203
# in the `var.instances` map. See next line for rough pattern to follow for all instances in your cluster
202-
# terraform state mv 'module.cluster_before.aws_rds_cluster_instance.this[<n>]' 'module.cluster_after.aws_rds_cluster_instance.this["<key>"]'
204+
# terraform state mv 'module.cluster_before.aws_rds_cluster_instance.this[<index>]' 'module.cluster_after.aws_rds_cluster_instance.this["<key>"]'
203205

204206
terraform state mv 'module.cluster_before.aws_appautoscaling_policy.autoscaling_read_replica_count[0]' 'module.cluster_after.aws_appautoscaling_policy.this[0]'
205207
terraform state mv 'module.cluster_before.aws_appautoscaling_target.read_replica_count[0]' 'module.cluster_after.aws_appautoscaling_target.this[0]'
206208
```
207209

208-
:info: Notes
210+
For example, if you previously had a configuration such as (truncated for brevity):
211+
212+
```hcl
213+
module "aurora" {
214+
215+
instance_type = "db.r5.large"
216+
instance_type_replica = "db.t3.medium"
217+
replica_count = 2
218+
replica_scale_enabled = true
219+
replica_scale_min = 2
220+
replica_scale_max = 5
221+
```
222+
223+
After updating the configuration to the latest 6.x changes:
224+
225+
```hcl
226+
module "aurora" {
227+
228+
instance_class = "db.r5.large"
229+
instances = {
230+
1 = {
231+
promotion_tier = 1
232+
}
233+
2 = {
234+
instance_class = "db.t3.medium"
235+
promotion_tier = 2
236+
}
237+
238+
autoscaling_enabled = true
239+
autoscaling_min_capacity = 2
240+
autoscaling_max_capacity = 5
241+
```
242+
243+
The associated Terraform state move commands would be:
244+
245+
```bash
246+
terraform state mv 'module.aurora.aws_rds_cluster_instance.this[0]' 'module.aurora.aws_rds_cluster_instance.this["1"]'
247+
terraform state mv 'module.aurora.aws_rds_cluster_instance.this[1]' 'module.aurora.aws_rds_cluster_instance.this["2"]'
209248

210-
- TODO
249+
terraform state mv 'module.aurora.aws_appautoscaling_policy.autoscaling_read_replica_count[0]' 'module.aurora.aws_appautoscaling_policy.this[0]'
250+
terraform state mv 'module.aurora.aws_appautoscaling_target.read_replica_count[0]' 'module.aurora.aws_appautoscaling_target.this[0]'
251+
```
252+
253+
### Configuration Changes
254+
255+
To avoid re-creation of the security group created by the module, you can add the following attribute and value:
256+
```hcl
257+
security_group_description = "Managed by Terraform"
258+
```

0 commit comments

Comments
 (0)