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

Failed to read schema for any Azure resource #501

Open
Ghostw4lk opened this issue Feb 9, 2024 · 2 comments
Open

Failed to read schema for any Azure resource #501

Ghostw4lk opened this issue Feb 9, 2024 · 2 comments
Labels
question Further information is requested

Comments

@Ghostw4lk
Copy link

Ghostw4lk commented Feb 9, 2024

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?

@Ghostw4lk Ghostw4lk changed the title Failed to read schema for any resource Failed to read schema for any Azure resource Feb 9, 2024
@stemaMSFT
Copy link
Member

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?

@magodo
Copy link
Collaborator

magodo commented Feb 19, 2024

@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.

@magodo magodo added the question Further information is requested label Feb 19, 2024
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

3 participants