I’ve been working on DRYing up my DNS configuration with a module. That means that the names of all my resources change. For example
before: dnsimple_record.example_com
after: module.dns-entry.dnsimple_record.this
When I run terraform plan
, it tells me it’s going to delete dnsimple_record.example_com
and create module.dns-entry.dnsimple_record.this
. But that makes it hard to tell whether the work I’m doing is a true refactor – that is, whether it would cause any changes.
I can remove the existing object from the state and import it under the new name:
$ terraform state rm dnsimple_record.example_com
$ terraform import module.dns-entry.dnsimple_record.this example.com_123456
I don’t love this since it affects the shared state. I’m still working locally. Nobody else has seen my code. I would only want to make that change after a pull request review.
So I’d love to be able to do something like
$ terraform plan -with=module.dns-entry.dnsimple_record.this:example.com_123456
to tell terraform that it should – for the scope of this command only – treat example.com_123456
as being defined by module.dns-entry.dnsimple_record.this
rather than dnsimple_record
.