Query with recursive doesn't generate output file
Hi all,
I had ran the command aztfexport query -r -o "file destination" "type =~ 'microsoft.apimanagement/service'" which generated a list of all the resources that I wanted exported.
I ran the import and once it was completed, there was no .tf file with the content from the import saved in the output directory.
@bjewell2x Per my test, there is one resource: azurerm_api_management_subscription failed to be imported. In that case, you'll be brought back to the interactive resource list view, and you can move your focus to the failed one and press e to see the error message. In this case, you'd have to press delete to skip it from importing.
The upstream issue: https://github.com/hashicorp/terraform-provider-azurerm/issues/21249
I think this bug and a few others in this list touch on a critical issue with this tool.
As far as I can tell, the issue is that knowing what the problem is with aztfexport is going to be challenging at best, if not impossible if an error occurs.
THEN, aztfexport doesn't just import everything that it states was "successfully imported". Instead it throws the import screen up again and then will just fail if you try to import again.
OBVIOUSLY, the expected behaviour should be that it imports everything that was possible to import. It's not like anyone is going to use this terraform directly, because it's not setup that way to be reasonable. What we'll do is, look at the resources that aztfexport exported, copy/paste the ones one need into our real terraform project. Sure, create an error list of stuff it couldn't import, but don't block what it could. I ran a project that took over an hour for it to run, and then it just throws all that work away? Clearly, this could be better.
@dloukola Thank you for the suggestion! In fact, we have several ways to continue exporting:
- In interactive mode, when you were brought back to the import screen, you can just select those failed ones and press delete to ignore them, and then press w to continue.
- On the other hand, you can specify
--continuein non-interactive mode (i.e.-n), in which case the process will proceed to the end and print error to stderr if any.
I'll try it! Maybe the issue is more of a message and docs problem. It's not really clear why it goes back to the import list, but now I know!
Hi @magodo , so I tried clicking delete on all the items that came up after the first export. Then after than completed I just get converting from state to configurations: converting terraform state to config: invalid resource address. Is there something else I should be doing?
@dloukola You'll need to keep the exported items, only delete the items that failed/you want to ignore.
:wave:
Since we've not heard back here I'm going to close this issue for the moment. Feel free to reopen if still have questions.