aztfexport
aztfexport copied to clipboard
Failed to read schema for any Azure resource
Hi all,
I want to export a specific Azure resource (PostgreSQL Flexible Server) to Terraform.
The environment details are the following:
- Azure VM (B2s) | 2 CPU / 4 GB RAM (AMD64)
- RHEL 8
- aztfexport version: v0.14.0(fb772ba)
- Terraform version: 1.7.3
- I am logged in through Azure CLI and set the subscription, where I want to export the resources.
- The Terraform version 3.77.0 has also the permission to execute: -rwxr-xr-x. 1 xxxx xxxx 252895232 Feb 9 13:52 terraform-provider-azurerm_v3.77.0_x5
To export the resource, I executed the following command: [xxxxx@terraform-vm terraform-export]$ aztfexport query -n "resourceGroup =~ 'MY_RESOURCE_GROUP' and type contains 'Microsoft.DB'"
Error: Failed to import /subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/MY_RESOURCE_GROUP/providers/Microsoft.DBforPostgreSQL/flexibleServers/test-db as azurerm_postgresql_flexible_server.res-0: exit status 1
Error: failed to read schema for azurerm_postgresql_flexible_server.res-0 in registry.terraform.io/hashicorp/azurerm: failed to instantiate provider "registry.terraform.io/hashicorp/azurerm" to obtain schema: fork/exec .terraform/providers/registry.terraform.io/hashicorp/azurerm/3.77.0/linux_amd64/terraform-provider-azurerm_v3.77.0_x5: permission denied
My user has the permission to read the resource group. I am able to get the whole list of 2637 items in that resource group through the following command: aztfexport resource-group MY_RESOURCE_GROUP
If I import a Azure resource through the command "terraform import", it works for me.
What could be the issue, that I can not export any Azure resource to Terraform?
Hey @Ghostw4lk are you able to export other resources, or is it not working for any resource? There's ways to configure what credentials you use in aztfexport, does the same error occur if you run with the flag --use-azure-cli-cred
?
@Ghostw4lk The issue may cause by tmp
is noexec
on your OS. aztfexport
under the hood will import the resources in parallel in the tmp dir. You can export TMPDIR
to somewhere else to work around the issue. E.g. run export TMPDIR=~/tmp
before running aztfexport
to specify ~/tmp
as the tmp dir.
: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.