Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query with recursive doesn't generate output file #384

Closed
bjewell2x opened this issue Mar 31, 2023 · 7 comments
Closed

Query with recursive doesn't generate output file #384

bjewell2x opened this issue Mar 31, 2023 · 7 comments
Labels
bug Something isn't working upstream-provider

Comments

@bjewell2x
Copy link

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.

@magodo
Copy link
Collaborator

magodo commented Apr 3, 2023

@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: hashicorp/terraform-provider-azurerm#21249

@magodo magodo added bug Something isn't working upstream-provider labels Apr 3, 2023
@dloukola
Copy link

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.

@magodo
Copy link
Collaborator

magodo commented May 15, 2023

@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 --continue in non-interactive mode (i.e. -n), in which case the process will proceed to the end and print error to stderr if any.

@dloukola
Copy link

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!

@dloukola
Copy link

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?

@magodo
Copy link
Collaborator

magodo commented May 17, 2023

@dloukola You'll need to keep the exported items, only delete the items that failed/you want to ignore.

@magodo
Copy link
Collaborator

magodo commented Aug 9, 2024

👋

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.

@magodo magodo closed this as completed Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream-provider
Projects
None yet
Development

No branches or pull requests

3 participants