Feature request: plan with rename

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.

Thanks for sharing this! I’m happy to raise this feedback with the engineering team :slight_smile:

Hi @jamesarosen! Thanks for sharing this.

For feature requests, it can be better to open them directly in GitHub so that it’ll be recorded with all the other feature requests and thus able to participate in the team’s prioritization processes.

However, in this case there happens to already be an issue covering this!

We have done some thinking around possible ways to achieve this through configuration and planning in future, and have some design sketches, but we’ve not been able to get that far enough along for full prototype and design yet due to our focus being in other areas right now. However, I do completely understand the use-case (I’ve run into it myself numerous times) and would love to move forward with a solution to this in a future release.

1 Like