aztfexport
aztfexport copied to clipboard
Import multiple resource groups into one state file.
Is there any way to import multiple resource groups in one single state.
I tried to --append command but fails.
I ran below commands on single empty dir. Sorry I'm new to this. Aztfy rg "rg name1" aztfy --append rg "rg name2"
Error: flag provided but not defined: -append
Error:
Hi @Akky8055 try aztfy rg —append
:)
You will also need to differentiate each set of resources by resource group within the generated .tf file otherwise you get the default "res-" prefix generated for each resource imported from each resource group - this will lead to immediate collisions with the "azurerm_resource_group.res-0" resource generated for each resource group
You get around this by invoking -p or --pattern { rg_specific_string } when you invoke aztfy
aztfy rg --append -p { rg_specific_string } { rg_name }
This will allow you to run aztfy rg --append multiple times in the same directory and it will ensure that there are no collisions in the exported/generated code
Of course you will still need to deal with the static/explicit dependencies, and re/create your modules from the exported .tfstate/ generated .tf files - but at least you don;t have to write it all from scratch
Cheers
-=A=-
.
@Akky8055 Instead of running the rg
subcommand with --append
multiple times, you can try the query
subcommand to query multiple resource groups under a subscription.
Since we haven't get further response from you, I'll mark this issue as closed for now. Feel free to reopen it if the issue still remains.