env0 / terratag

Terratag is a CLI tool that enables users of Terraform to automatically create and maintain tags across their entire set of AWS, Azure, and GCP resources
https://terratag.io
Mozilla Public License 2.0
937 stars 44 forks source link

AzureRM 4.4 - ERROR failed to process main.tf due to an error failed to execute 'tofu providers schema -json' command: exit status 11 #201

Open away168 opened 6 days ago

away168 commented 6 days ago

Describe the bug

Using latest azurerm provider version 4.4 (maybe) causes Terratag to fail.

> /opt/terratag -tags="{\"created_by\":\"$ENV0_ENVIRONMENT_CREATOR_NAME\",\"env0_environment_id\":\"xxxx\",\"env0_project_id\":\"xxxxx\"}" -rename=false 
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/vm_win/variables.tf
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/vm_lin/outputs.tf
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/user_data_puppet/variables.tf
2024/10/09 19:43:11 [INFO] No taggable resources found in file .terraform/modules/vm_lin/outputs.tf - skipping
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/vm_lin/main.tf
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/vm_win/main.tf
2024/10/09 19:43:11 [INFO] No taggable resources found in file .terraform/modules/user_data_puppet/variables.tf - skipping
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/vm_lin/variables.tf
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/vm_win/outputs.tf
2024/10/09 19:43:11 [INFO] Processing file providers.tf
2024/10/09 19:43:11 [INFO] Processing file main.tf
2024/10/09 19:43:11 [INFO] Processing file outputs.tf
2024/10/09 19:43:11 [INFO] Processing file variable.tf
2024/10/09 19:43:11 [INFO] Processing file env0_remote_backend_override.tf
2024/10/09 19:43:11 [INFO] Processing file infoblox.tf
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/user_data_puppet/main.tf
2024/10/09 19:43:11 [INFO] Processing file .terraform/modules/user_data_puppet/outputs.tf
2024/10/09 19:43:11 [INFO] No taggable resources found in file .terraform/modules/user_data_puppet/outputs.tf - skipping
2024/10/09 19:43:11 [INFO] No taggable resources found in file providers.tf - skipping
2024/10/09 19:43:11 [INFO] No taggable resources found in file env0_remote_backend_override.tf - skipping
2024/10/09 19:43:11 [INFO] No taggable resources found in file .terraform/modules/vm_win/variables.tf - skipping
2024/10/09 19:43:11 [INFO] No taggable resources found in file outputs.tf - skipping
2024/10/09 19:43:11 [INFO] No taggable resources found in file .terraform/modules/vm_win/outputs.tf - skipping
2024/10/09 19:43:11 [INFO] No taggable resources found in file infoblox.tf - skipping
2024/10/09 19:43:11 [INFO] No taggable resources found in file .terraform/modules/user_data_puppet/main.tf - skipping
2024/10/09 19:43:11 [INFO] Processing resource [azurerm_public_ip default]
2024/10/09 19:43:11 [INFO] Processing resource [azurerm_resource_group default]
2024/10/09 19:43:11 [INFO] No taggable resources found in file variable.tf - skipping
2024/10/09 19:43:11 [INFO] Processing resource [azurerm_public_ip default]
2024/10/09 19:43:11 [INFO] No taggable resources found in file .terraform/modules/vm_lin/variables.tf - skipping
2024/10/09 19:43:21 [ERROR] failed to process .terraform/modules/vm_win/main.tf due to an error
failed to execute 'tofu providers schema -json' command: exit status 11
2024/10/09 19:43:28 [ERROR] failed to process main.tf due to an error
failed to execute 'tofu providers schema -json' command: exit status 11
2024/10/09 19:43:35 [ERROR] failed to process .terraform/modules/vm_lin/main.tf due to an error
failed to execute 'tofu providers schema -json' command: exit status 11
2024/10/09 19:43:35 [INFO] Summary:
2024/10/09 19:43:35 [INFO] Tagged 0 resource/s (out of 0 resource/s processed)
2024/10/09 19:43:35 [INFO] In 0 file/s (out of 15 file/s processed)

To Reproduce A minimal Terraform configuration reproducing the issue:


terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "4.4.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "foo" {
  name = "foo"
  location = "westus"
}

terratag -tags="{\"created_by\":\"John Smith\",\"env0_environment_id\":\"555\",\"env0_project_id\":\"777\"}" -rename=false

the following resources were not tagged:

azurerm_resource_group
azurerm_disk_access
azurerm_linux_virtual_machine
azurerm_network_interface
azurerm_private_endpoint
azurerm_virtual_machine_extension

Expected behavior tag

Additional context running in env0 / opentofu latest (1.8.3) locally - terratag 0.4.0 / opentofu 1.7 / 1.8.2 - could not reproduce locally env0 terratag 0.3.5 - could reproduce in env0.

Workaround n/a

away168 commented 6 days ago

I could not reproduce this locally using OpenTofu 1.7 / 1.8.2

away168 commented 6 days ago

was able to reproduce this issue in env0; terratag 0.3.5 (in env0) and OpenTofu 1.7

away168 commented 6 days ago

I now believe it is a memory issue. The json response is 2.9Mb.