Closed zayhanlon closed 1 year ago
We are happy to have received all the feedback we got from the new Terraform module for Fleet! Its been really great! One thing we consistently got though was confusion on how to migrate from current Dogfood code to the Terraform module. Due to the large variety of situations, there's still not a hard and fast "this is how to do it" that we can give, but I'll present two methods that should work in most situations.
By far the easiest method is to just take a snapshot of the existing databse, and then pass that into the module when you apply. This will cause downtime since it will recreate all resources, but based on feedback from customers this is acceptable in most situations. Here is a step by step guide on how to migrate using this method:
terraform validate
to ensure it will work)snapshot_identifier
field of the rds_config
variable.terraform apply -target module.main.module.vpc
. Change the target to match what you named the module if you changed the name.terraform apply
to apply the rest of the changesterraform apply -target module.<addon>
first so that IAM policies are created. Terraform can get confused if the policies are not available at plan time.This is a harder method, but can result in less or even no downtime. In short, terraform added a new feature that lets users rename resources: https://developer.hashicorp.com/terraform/language/modules/develop/refactoring We can use this feature to rename most or even all resources, resulting in less downtime. Below is the code we have written to migrate the "heavy" resources to the module:
moved {
from = module.vpc
to = module.main.module.vpc
}
moved {
from = module.aurora_mysql
to = module.main.module.byo-vpc.module.rds
}
moved {
from = aws_elasticache_replication_group.default
to = module.main.module.byo-vpc.module.redis.aws_elasticache_replication_group.default
}
This doesn't target all resources, and will still result in downtime, but it should be a lot lower. Here is a step by step guide to help you through this method:
terraform apply -target module.main.module.vpc
.terraform plan
, carefully examining the provided plan. Do not actually run the apply yet.Requested an update from JD and Nate Holliday on this doc
its out of my hands, closing
Cloud city's haze glows,
Secured fleets, modular now.
Ease of deployment flows.
Pass technical draft to Jarod and JD Strong for final review and publishing