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

Error: The terraform-provider-azurerm_v3.1.0_x5.exe plugin crashed! #24186

Closed
1 task done
lviswanath opened this issue Dec 11, 2023 · 2 comments
Closed
1 task done

Error: The terraform-provider-azurerm_v3.1.0_x5.exe plugin crashed! #24186

lviswanath opened this issue Dec 11, 2023 · 2 comments

Comments

@lviswanath
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.1.5

AzureRM Provider Version

3.1.0

Affected Resource(s)/Data Source(s)

azurerm_virtual_machine

Terraform Configuration Files

backend:
terraform {
  required_version = "~> 1.1.5"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=3.1.0"
    }
  }
}
module : 
resource "azurerm_virtual_machine" "virtual_machine" {
  for_each              = var.virtual_machines
  name                  = each.value["name"]
  location              = each.value["location"]
  resource_group_name   = each.value["resource_group_name"]
  network_interface_ids = [for network_interface in each.value["network_interface_variable_name"] : var.network_interface_ids[network_interface] if contains(keys(var.network_interface_ids), network_interface)]
  dynamic "os_profile_windows_config" {
    for_each = each.value["enable_os_profile_windows_config"] == true ? [1] : []
    content {
      provision_vm_agent        = each.value.os_profile_windows_config["provision_vm_agent"]
      enable_automatic_upgrades = each.value.os_profile_windows_config["enable_automatic_upgrades"]
      timezone                  = each.value.os_profile_windows_config["timezone"]
      dynamic "winrm" {
        for_each = each.value.os_profile_windows_config["winrm"]
        content {
          protocol        = winrm.value["protocol"]
          certificate_url = winrm.value["certificate_url"]
        }
      }
      dynamic "additional_unattend_config" {
        for_each = each.value.os_profile_windows_config["enable_additional_unattend_config"] == true ? [1] : []
        content {
          pass         = each.value.os_profile_windows_config.additional_unattend_config["pass"]
          component    = each.value.os_profile_windows_config.additional_unattend_config["component"]
          setting_name = each.value.os_profile_windows_config.additional_unattend_config["setting_name"]
          content      = each.value.os_profile_windows_config.additional_unattend_config["content"]
        }
      }
    }
  }
  dynamic "os_profile_linux_config" {
    for_each = each.value["enable_os_profile_linux_config"] == true ? [1] : []
    content {
      disable_password_authentication = each.value.os_profile_linux_config["disable_password_authentication"]
      dynamic "ssh_keys" {
        for_each = each.value.os_profile_linux_config["ssh_keys"]
        content {
          key_data = ssh_keys.value["key_data"]
          path     = ssh_keys.value["path"]
        }
      }
    }
  }
  vm_size             = each.value["vm_size"]
  availability_set_id = each.value["availability_set_id"]
  dynamic "boot_diagnostics" {
    for_each = each.value["enable_boot_diagnostics"] == true ? [1] : []
    content {
      enabled     = true
      storage_uri = each.value.boot_diagnostics["storage_uri"]
    }
  }
  dynamic "additional_capabilities" {
    for_each = each.value.additional_capabilities["ultra_ssd_enabled"] == true ? [1] : []
    content {
      ultra_ssd_enabled = true
    }
  }
  delete_os_disk_on_termination    = each.value["delete_os_disk_on_termination"]
  delete_data_disks_on_termination = each.value["delete_data_disks_on_termination"]
  dynamic "identity" {
    for_each = each.value["enable_identity"] == true ? [1] : []
    content {
      type = each.value.identity["type"]
    }
  }
  license_type = each.value["license_type"]
  dynamic "os_profile" {
    for_each = each.value["enable_os_profile"] == true ? [1] : []
    content {
      computer_name  = each.value.os_profile["computer_name"]
      admin_password = each.value.os_profile["admin_password"]
      admin_username = each.value.os_profile["admin_username"]
    }
  }
  dynamic "os_profile_secrets" {
    for_each = each.value["os_profile_secrets"]
    content {
      source_vault_id = os_profile_secrets.value["source_vault_id"]
      dynamic "vault_certificates" {
        for_each = each.value.os_profile_secrets["vault_certificates"]
        content {
          certificate_url   = vault_certificates.value["certificate_url"]
          certificate_store = vault_certificates.value["certificate_store"]
        }
      }
    }
  }
  dynamic "plan" {
    for_each = each.value["enable_plan"] == true ? [1] : []
    content {
      name      = each.value.plan["name"]
      publisher = each.value.plan["publisher"]
      product   = each.value.plan["product"]
    }
  }
  primary_network_interface_id = lookup(var.network_interface_ids, each.value["primary_network_interface_variable_name"], null)
  dynamic "storage_data_disk" {
    for_each = each.value["storage_data_disk"]
    content {
      name                      = storage_data_disk.value["name"]
      caching                   = storage_data_disk.value["caching"]
      create_option             = storage_data_disk.value["create_option"]
      disk_size_gb              = storage_data_disk.value["disk_size_gb"]
      lun                       = storage_data_disk.value["lun"]
      write_accelerator_enabled = storage_data_disk.value["write_accelerator_enabled"]
    }
  }
  dynamic "storage_image_reference" {
    for_each = each.value["enable_storage_image_reference"] == true ? [1] : []
    content {
      publisher = each.value.storage_image_reference["publisher"]
      offer     = each.value.storage_image_reference["offer"]
      sku       = each.value.storage_image_reference["sku"]
      version   = each.value.storage_image_reference["version"]
    }
  }
  storage_os_disk {
    name                      = each.value.storage_os_disk["name"]
    caching                   = each.value.storage_os_disk["caching"]
    create_option             = each.value.storage_os_disk["create_option"]
    disk_size_gb              = each.value.storage_os_disk["disk_size_gb"]
    image_uri                 = each.value.storage_os_disk["image_uri"]
    os_type                   = each.value.storage_os_disk["os_type"]
    write_accelerator_enabled = each.value.storage_os_disk["write_accelerator_enabled"]
  }
  tags = each.value["virtual_machine_tags"]
}

variables:
variable "virtual_machines" {
  type = map(object({
    name                             = string
    location                         = string
    resource_group_name              = string
    network_interface_variable_name  = list(string)
    enable_os_profile_windows_config = bool
    os_profile_windows_config = object({
      provision_vm_agent        = bool
      enable_automatic_upgrades = bool
      timezone                  = string
      winrm = map(object({
        protocol        = string
        certificate_url = string
      }))
      enable_additional_unattend_config = bool
      additional_unattend_config = object({
        pass         = string
        component    = string
        setting_name = string
        content      = string
      })
    })
    enable_os_profile_linux_config = bool
    os_profile_linux_config = object({
      disable_password_authentication = bool
      ssh_keys = map(object({
        key_data = string
        path     = string
      }))
    })
    vm_size                 = string
    availability_set_id     = string
    enable_boot_diagnostics = bool
    boot_diagnostics = object({
      storage_uri = string
    })
    additional_capabilities = object({
      ultra_ssd_enabled = bool
    })
    delete_os_disk_on_termination    = bool
    delete_data_disks_on_termination = bool
    enable_identity                  = bool
    identity = object({
      type = string
    })
    license_type      = string
    enable_os_profile = bool
    os_profile = object({
      computer_name  = string
      admin_password = string
      admin_username = string
    })
    os_profile_secrets = map(object({
      source_vault_id = string
      vault_certificates = map(object({
        certificate_url   = any
        certificate_store = string
      }))
    }))
    enable_plan = bool
    plan = object({
      name      = string
      publisher = string
      product   = string
    })
    primary_network_interface_variable_name = string
    storage_data_disk = map(object({
      name                      = string
      caching                   = string
      create_option             = string
      disk_size_gb              = number
      lun                       = number
      write_accelerator_enabled = bool
    }))
    enable_storage_image_reference = bool
    storage_image_reference = object({
      publisher = string
      offer     = string
      sku       = string
      version   = string
    })
    storage_os_disk = object({
      name                       = string
      caching                    = string
      create_option              = string
      disk_size_gb               = number
      image_uri                  = string
      os_type                    = string
      write_accelerator_enabled  = bool
      is_managed_disk_used       = bool
      managed_disk_variable_name = string
      managed_disk_type          = string
    })
    virtual_machine_tags = map(string)
  }))
}

variable "network_interface_ids" {
  type    = map(string)
  default = {}
}

variable "managed_disk_ids" {
  type    = map(string)
  default = {}
}

tfvars:

virtual_machines = {
  vmcac1 = {
    name                             = "vmcac1"
    location                         = "canadacentral"
    resource_group_name              = "rg-cac-01"
    network_interface_variable_name  = ["vmcac1-nic"]
    enable_os_profile_windows_config = false
    os_profile_windows_config = {
      provision_vm_agent                = false
      enable_automatic_upgrades         = false
      timezone                          = null
      winrm                             = {}
      enable_additional_unattend_config = false
      additional_unattend_config = {
        pass         = ""
        component    = ""
        setting_name = ""
        content      = ""
      }
    }
    enable_os_profile_linux_config = false
    os_profile_linux_config = {
      disable_password_authentication = false
      ssh_keys                        = {}
    }
    vm_size                 = "Standard_D4s_v3"
    availability_set_id     = null
    enable_boot_diagnostics = false
    boot_diagnostics = {
      storage_uri = ""
    }
    additional_capabilities = {
      ultra_ssd_enabled = false
    }
    delete_os_disk_on_termination    = null
    delete_data_disks_on_termination = null
    enable_identity                  = false
    identity = {
      type = "SystemAssigned"
    }
    license_type      = null
    enable_os_profile = false
    os_profile = {
      computer_name  = ""
      admin_password = ""
      admin_username = ""
    }
    os_profile_secrets = {}
    enable_plan        = false
    plan = {
      name      = ""
      publisher = ""
      product   = ""
    }
    primary_network_interface_variable_name = "vmcac1-nic"
    storage_data_disk                       = {}
    enable_storage_image_reference          = false
    storage_image_reference = {
      publisher = ""
      offer     = ""
      sku       = ""
      version   = ""
    }
    storage_os_disk = {
      name                       = "vmcac1-osdisk"
      caching                    = "ReadWrite"
      create_option              = "Attach"
      disk_size_gb               = 127
      image_uri                  = null
      os_type                    = "Windows"
      write_accelerator_enabled  = false
      is_managed_disk_used       = true
      managed_disk_variable_name = "vmcac1-osdisk"
      managed_disk_type          = "Premium_LRS"
    }
    virtual_machine_tags = {
      applicationName = "Windows VM"
      approver        = "IT Infrastructure"
    }
  }
}

module call :
module "virtual_machine" {
  source                = "./compute/virtual_machine"
  virtual_machines      = var.virtual_machines
  network_interface_ids = module.network_interface.id
  managed_disk_ids      = module.managed_disk.id
  depends_on            = [module.resource_group]
}

Debug Output/Panic Output

Error: Plugin did not respond
│
│   with module.virtual_machine.azurerm_virtual_machine.virtual_machine["vmcac1"],
│   on .\compute\virtual_machine.tf line 1, in resource "azurerm_virtual_machine" "virtual_machine":
│    1: resource "azurerm_virtual_machine" "virtual_machine" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin  
│ logs may contain more details.
╵
╷
│ Error: Plugin did not respond
│
│   with module.windows_virtual_machine.azurerm_windows_virtual_machine.windows_virtual_machine["vmpmpcnpcac1"],      
│   on .\compute\windows_virtual_machine\windows_virtual_machine.tf line 1, in resource "azurerm_windows_virtual_machine" "windows_virtual_machine":
│    1: resource "azurerm_windows_virtual_machine" "windows_virtual_machine" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin  
│ logs may contain more details.
╵
Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-azurerm_v3.1.0_x5.exe plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x4746fa9]

goroutine 554 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/legacy.flattenAzureRmVirtualMachineOsProfile(...)   
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/internal/services/legacy/virtual_machine_resource.go:1277
github.com/hashicorp/terraform-provider-azurerm/internal/services/legacy.resourceVirtualMachineRead(0xc001b09200, {0x5144860?, 0xc0009fe000})
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/internal/services/legacy/virtual_machine_resource.go:877 +0xd29
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x5a3d569?, {0x616a228?, 0xc001e26180?}, 0x24?, {0x5144860?, 0xc0009fe000?})
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource.go:346 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000e63dc0, {0x616a228, 0xc001e26180}, 0xc001e2dad0, {0x5144860, 0xc0009fe000})
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/resource.go:635 +0x35b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00051c3f0, {0x616a228, 0xc001e26180}, 0xc001e26200)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/grpc_provider.go:576 +0x43f
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0001b7880, {0x616a2d0?, 0xc001a12000?}, 0xc0023f4060)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:553 +0x33c
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x5690300?, 0xc0001b7880}, {0x616a2d0, 0xc001a12000}, 0xc0023f4000, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001ff180, {0x617b230, 0xc000189c80}, 0xc001b12b40, 0xc00147d950, 
0x9fd17d0, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1292 +0xc6f
google.golang.org/grpc.(*Server).handleStream(0xc0001ff180, {0x617b230, 0xc000189c80}, 0xc001b12b40, 0x0)
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1617 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:940 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor

Error: The terraform-provider-azurerm_v3.1.0_x5.exe plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Expected Behaviour

terraform plan should show that there are no changes to configuration

Actual Behaviour

Throwing the provided error

Steps to Reproduce

terraform init
terraform plan

Important Factoids

No response

References

No response

@rcskosir
Copy link
Contributor

@lviswanath Thank you for taking the time to create this issue. There is a fix for this crash in v3.76.0 with this PR #23535, so upgrading will resolve this issue for you. As such, I am going to mark this issue as resolved.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants