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

Aztfy not importing VM #122

Closed
justPaulo opened this issue May 28, 2022 · 5 comments
Closed

Aztfy not importing VM #122

justPaulo opened this issue May 28, 2022 · 5 comments
Labels
question Further information is requested

Comments

@justPaulo
Copy link

justPaulo commented May 28, 2022

Is there any special reason why Azure resources like Virtual Machines are not imported? Googled around and found more people with the same issue. There's even an automatically generated comment in the created code, example:

...
depends_on = [
# Depending on "/subscriptions/xxxxxxxxx/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/vm", which is not imported by Terraform.
]
...

@magodo
Copy link
Collaborator

magodo commented May 29, 2022

@justPaulo This is due to currently given the resource id of a VM, aztfy is isn't able to detect whether you want to import it as a azurerm_linux_virtual_machine, azurerm_windows_virtual_machine or azurerm_virtual_machine. Therefore, users are expected to type the resource type for it. This will be improved in a later version, where it will call Azure API to determine the type.

@magodo magodo added the question Further information is requested label May 29, 2022
@justPaulo
Copy link
Author

Hello @magodo
Thank you for your answer.
Unfortunately, I don't quite get it because unlike other GitHub tools like az2tf or terraformer where the VM resource types are indeed imported, regardless they are Linux or Windows VMs, I don't see it happen with aztfy. Also unlike the mentioned tools, I don't see how to specify the import of a specific Azure resource like a VM, example:
"terraformer import azure -r <> -R virtual_machine"
Is there any equivalent under aztfy?
And when you say "...aztfy is able to detect whether you want to import it as a azurerm_linux_virtual_machine, azurerm_windows_virtual_machine or azurerm_virtual_machine." does this mean there's an aztfy syntax allowing to specific such a resource?

Thanks,

@magodo
Copy link
Collaborator

magodo commented May 30, 2022

@justPaulo Sorry that is a typo, I really mean "isn't able to"... Currently, aztfy only works to specify a resource group and import the containing resources, if there is a VM in it, you can specify which TF type you want to import it as (azurerm_linux_virtual_machine, azurerm_windows_virtual_machine or azurerm_virtual_machine).

You can check out this blog for a live walk through: https://www.kmruddy.com/2022/terrafy-existing-azure-resources.

@justPaulo
Copy link
Author

justPaulo commented Jun 7, 2022

@magodo no worries. Now I understand that actually, one has to "select" the resource marked with "Skip" to have it terraformed. However, the logic of skipping some resources and others not, escapes me...

@magodo
Copy link
Collaborator

magodo commented Jul 21, 2022

aztfy can auto deduce the correct VM type now (#175).

@magodo magodo closed this as completed Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants