I’ve been advised that there is an unofficial feature of Terraform which allows for chained moves.
i.e.
moved {
from = aws_route_table_association.tn
to = aws_route_table_association.cust
}
moved {
from = aws_route_table_association.cust
to = aws_route_table_association.private
}
However I’ve been struggling to implement it, as Terraform appears to ignore my first ‘move’ in the chain.
For context, both resources had for_each set (I’ve seen a GH issue being resolved with regards to moving from a non iterated resource to a count (Cyclic dependency error when both the parent and the child module have moved
block. · Issue #30208 · hashicorp/terraform · GitHub))
These are non-overlapping resources.
aws_route_table_association.tn has awsenpt.eu-west-1
, transitgw.eu-west-1
aws_route_table_association.cust has foo.eu-west-1
, bar.eu-west-1
I would expect the chain of custody for the resources to pass along, however Terraform successfully moves cust -> private
, but ignores tn -> cust
.
This can be worked around, by moving single elements directly:
moved {
from = aws_route_table_association.tn["awsenpt.eu-west-1"]
to = aws_route_table_association.private["awsenpt.eu-west-1"]
}
But it would be way neater if I could combine them in one.
If it’s worth mentioning - this called from within a module.
modules/vpc
route_table.tf
route_table-moved.tf <-- here
Terraform 1.7.2
Provider version latest v4 AWS.
Tried:
TF 1.7.5, 1.8.x
Provider version v5