Terraform Bulk Import Proposal

Recently I went through a bit of the terraformer project and have some findings, e.g.

  1. The part it convert the state to terraform config is buggy. For those nested computed attributes (maybe even more) will not be skipped in the terraform config. Addtionally, I wonder whether those conflicts attributes should also be handled correctly (e.g. attributes with ExactlyOneOf set)
  2. The part it resolve dependencies among resources seems buggy (where it uses the term of “connection” instead). It can’t bear with multiple depended attributes.
  3. The support on azure seems buggy and poor.
  4. Though the intention of this tool is to decouple from provider. Whilst it do couples with provider in different ways. One of them is that you will needs to specify the dependency(connection) in the code, where those attributes are coupled with a specific provider version.

Based on above limitations, I feel like there still are some core problems to be solved in Terraformer, mostly including below ones:

  1. How to convert from terraform state to terraform config (without dependency)?
  2. How to add dependency to a terraform config (while the dependency info is coupled with the provider)?

Then I come up with following design:

For the TBD part, I assume that we can somehow add an option to terraform show so that it could output the valid terraform config (which addresses the 1st core problem).

I want to hear about everyones opinions on this before implementing it. Especially make sure it doesn’t conflict with the roadmap of core team.

I just submit a PR to add the -input option for terraform show so that Terraform can output a valid config file (with output attributes stripped).

Hi @magodo1! Thanks for posting this interesting proposal.

The Terraform core team are busy working on other projects for Terraform 0.14 and beyond, and we don’t intend to focus on terraform import until after Terraform 1.0 is released. The ideas in your proposal seem reasonable to me, but I don’t think the core team will be able to give more detailed feedback for several months. Sorry for the delay!

1 Like

Hi @magodo1 ! You might be interested in the new terraform add configuration generation command that I’m working on, targeted for the 1.1 release. It’s not merged yet, but if it’s something you want to try out ahead of time, you can build Terraform from the branch in this PR and let us know if you have any feedback (if you have any feedback after that PR is merged, please open a new github issue).

1 Like

Hi @mildwonkey! Thank you for the great effort here :+1: I’ve tried it and found some potential issues. Also I’ve made a PR to fixing one of them: `terraform add`: `-out` option append to existing config & optionally check resource existance by magodo · Pull R. Maybe you’d like to take a look?