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 skips storage accounts #156

Closed
andyghc opened this issue Jun 23, 2022 · 9 comments
Closed

aztfy skips storage accounts #156

andyghc opened this issue Jun 23, 2022 · 9 comments
Labels
question Further information is requested

Comments

@andyghc
Copy link

andyghc commented Jun 23, 2022

When running aztfy on a resource group that only has a storage account, the aztfy command skips over the storage account. No reason given for why it's being skipped, it just lists all the resources and lists (Skip) with each of them.

` Azure Terrafy

 EQ_Azure_RG_Mgmt01_CostMgt

7 items

│ /subscriptions/xxx-yyy-zzz/resourceGroups/Test_RG/providers/Microsoft.Storage/storageAccounts/myteststoracc538asd
│ (Skip)

/subscriptions/xxx-yyy-zzz/resourceGroups/Test_RG/providers/Microsoft.Storage/storageAccounts/myteststoracc538asd/blobServices/de
(Skip)

/subscriptions/xxx-yyy-zzz/resourceGroups/Test_RG/providers/Microsoft.Storage/storageAccounts/myteststoracc538asd/fileServices/de
(Skip)

/subscriptions/xxx-yyy-zzz/resourceGroups/Test_RG/providers/Microsoft.Storage/storageAccounts/myteststoracc538asd/queueServices/d
(Skip)

/subscriptions/xxx-yyy-zzz/resourceGroups/Test_RG/providers/Microsoft.Storage/storageAccounts/myteststoracc538asd/tableServices/d
(Skip)

/subscriptions/xxx-yyy-zzz/resourceGroups/Test_RG/providers/Microsoft.Storage/storageAccounts/myteststoracc538asd/blobServices/de
(Skip)

💡/subscriptions/xxx-yyy-zzz/resourceGroups/Test_RG
azurerm_resource_group.res-6

`

@magodo
Copy link
Collaborator

magodo commented Jun 23, 2022

These are embedded service that are created together with the storage account. There is no correspondance in TF.

@magodo magodo added the question Further information is requested label Jun 23, 2022
@AlexLudwigITDienstleistungen

The same problem exists here. You can add the resource manually by specifying the name like azurerm_storage_account.StoAccName.
The problem also occurs with Key Vaults, Windows virtual machines and virtual machine extensions.
After manually declaring the names, the import runs correctly except for storage accounts that use Azure AD authentication.
Import for storage containers also fails with the following error message:

/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/VeeamVBO-dev/providers/Microsoft.Storage/storageAccounts/veeamvbodev/blobServices/default/containers/vbodata
exit status 1
Error: Cannot import non-existent remote object
While attempting to import an existing object to
"azurerm_storage_container.vbodata", the provider detected that no object
exists with the given id. Only pre-existing objects can be imported; check
that the id is correct and that it is associated with the provider's
configured region or endpoint, or use "terraform apply" to create a new
remote object for this resource.

@magodo As you can see, there is definitely an equivalent in terraform. This is the reason why I am totally confused why these objects are not recognized correctly.

@magodo
Copy link
Collaborator

magodo commented Jun 25, 2022

So you are trying to import the container rather than the storage account (as the ids in your issue description is truncated, I thought you were trying to import things like /subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/VeeamVBO-dev/providers/Microsoft.Storage/storageAccounts/veeamvbodev/blobServices/default).

The problem also occurs with Key Vaults, Windows virtual machines and virtual machine extensions.

Could you please provide more details for this?

@magodo magodo added bug Something isn't working and removed question Further information is requested labels Jun 25, 2022
@andyghc
Copy link
Author

andyghc commented Jun 25, 2022

Sorry yes, the output above was truncated. But there is nothing special going on here. I am running aztfy on a resource group with only one resource in it which is a storage account. Surely a storage account can be imported with aztfy right? I've seen it import much more complicated things like Application Gateway WAF's etc, but why skip a storage account?

Is there some sort of trick I need to run to import storage accounts?

Attached is the output of a simple aztfy command "aztfy <resource_group_name>" in an empty directory.

I'm using aztfy version: v0.5.0(f957fc1)

Screenshot 2022-06-25 112800

@magodo
Copy link
Collaborator

magodo commented Jun 25, 2022

From the README:

In interactive mode, aztfy list all the resources resides in the specified resource group. For each resource, user is expected to input the Terraform resource address in form of . (e.g. azurerm_linux_virtual_machine.test). Users can press r to see the possible resource type(s) for the selected import item (though this is not guaranteed to be 100% accurate). In case there is exactly one resource type match for the import item, that resource type will be automatically filled in the text input for the users, with a bulb line prefix as an indication.

The reason why it is showning skip is because aztfy isn't smart enough to know that resource corresponds to a storage account. You have to specify it yourselves. But we have some work going on to improve this.

@magodo magodo added question Further information is requested and removed bug Something isn't working labels Jun 25, 2022
@sosoriov
Copy link

@magodo I agree but at least it should generate the storage account definition in TF which is not happening in my case. It only generates the RG. I'm running v0.5.0

@magodo
Copy link
Collaborator

magodo commented Jul 20, 2022

@sosoriov You can try the latest main branch, which should be smart enough now to identify a storage account.

@sosoriov
Copy link

that did the trick. Thanks @magodo !

@magodo
Copy link
Collaborator

magodo commented Jul 21, 2022

This issue is fixed in the v0.6.0 (#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

4 participants