hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

Error: The terraform-provider-azurerm_v3.0.2_x5 plugin crashed! #16235

Open rohith267 opened 2 years ago

rohith267 commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.1.7

AzureRM Provider Version

3.0.2

Affected Resource(s)/Data Source(s)

azurerm_windows_function_app, azurerm_cosmosdb_sql_container, azurerm_storage_blob

Terraform Configuration Files


resource "azurerm_windows_function_app" "function" {
  depends_on = [
    module.function_storage
  ]

  service_plan_id             = local.config.service_plan_id
  daily_memory_time_quota     = local.config.daily_memory_time_quota
  https_only                  = local.config.https_only
  location                    = local.env_config.location
  name                        = local.function_name
  resource_group_name         = local.env_config.resource_group
  storage_account_access_key  = local.env_config.function_storage == 1 ? module.function_storage[0].storage_config.primary_access_key : local.code_config.primary_access_key
  storage_account_name        = local.env_config.function_storage == 1 ? module.function_storage[0].storage_config.name : local.code_config.name
  #functions_extension_version = local.config.version

  app_settings = merge(
    local.function_settings,
    {
      HASH                      = local.code_hash
      WEBSITE_RUN_FROM_PACKAGE  = "${azurerm_storage_blob.appcode.url}"
      AzureWebJobsStorage       = local.env_config.function_storage == 1 ? module.function_storage[0].storage_config.connection_string : local.code_config.connection_string
      IS_LOCAL                  = "false"
      STORAGE_CONNECTION_STRING = local.env_config.function_storage == 1 ? module.function_storage[0].storage_config.connection_string : local.code_config.connection_string
    }
  )

  tags = merge(local.env_config.tags,
    {
      "Name"     = local.function_name
      "Function" = "App"
    }
  )

  identity {
    type         = "SystemAssigned, UserAssigned"
    identity_ids = [local.identity_config.id]
  }

  site_config {
    cors {
      allowed_origins = local.site_config.cors
    }

    always_on                        = local.site_config.always_on
    app_scale_limit                  = local.site_config.app_scale_limit
    ftps_state                       = local.site_config.ftps_state
    http2_enabled                    = local.site_config.http2_enabled
    pre_warmed_instance_count        = 1
    runtime_scale_monitoring_enabled = local.site_config.runtime_scale_monitoring_enabled
    use_32_bit_worker                = local.site_config.use_32_bit_worker_process
  }

  lifecycle {
    create_before_destroy = true
  }
}

Debug Output/Panic Output

Error: Plugin did not respond
│ 
│   with module.Function_App.azurerm_windows_function_app.function,
│   on ../modules/shared/function_app/windows/main.tf line 123, in resource "azurerm_windows_function_app" "function":
│  123: resource "azurerm_windows_function_app" "function" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
│ contain more details.

**Similar issue observed with azurerm_cosmosdb_sql_container**.

 **And at last in the logs of terraform apply, the following error is shown.**

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

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x445f00a]

goroutine 659 [running]:

github.com/hashicorp/terraform-provider-azurerm/internal/sdk.diagnosticsWrapper.func1({0x668d5c8, 0xc001c9f0e0}, 0xc0019e76c0, {0x567d800, 0xc001b08380})
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/internal/sdk/wrapper_resource.go:185 +0xbe
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc0004236c0, {0x668d558, 0xc000a7fbc0}, 0x2, {0x567d800, 0xc001b08380})
    /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:341 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0004236c0, {0x668d558, 0xc000a7fbc0}, 0xc00104e1a0, 0xc00174c800, {0x567d800, 0xc001b08380})
    /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:467 +0x871
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0003851d0, {0x668d558, 0xc000a7fbc0}, 0xc001bc1b30)
    /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:977 +0xd8a
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000139180, {0x668d600, 0xc001618de0}, 0xc0002a3570)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:603 +0x30e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x5bc6ea0, 0xc000139180}, {0x668d600, 0xc001618de0}, 0xc000a0fe60, 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:380 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001af340, {0x66de508, 0xc001138c00}, 0xc0017b3440, 0xc000b5a5a0, 0xad5ef60, 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(0xc0001af340, {0x66de508, 0xc001138c00}, 0xc0017b3440, 0x0)
    /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1617 +0xa2a
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/google.golang.org/grpc/server.go:938 +0x294

Error: The terraform-provider-azurerm_v3.0.2_x5 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

The resources are created properly by using the azurerm version 2.98.0 . When we tried to upgrade the azurerm provider version to 3.0.2 and made the necessary changes that are mentioned in the hashicorp documentation, function app, cosmos db containers and storage blob should get created.

Actual Behaviour

The resources are not being created and the above error is being observed on the azure pipeline in 'terraform apply' step.

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

lonegunmanb commented 2 years ago

Hello @rohith267, I'd like to try a fix but unfortunately, I was unable to reproduce this crash on my side, would you please provide a minimal sample with all arguments that could reproduce this issue? Many thanks!

rohith267 commented 2 years ago

Hi @lonegunmanb , I will provide the minimal sample code replicating the issue in some time.

JackSinclairT commented 2 years ago

We experienced this issue yesterday as well. We ended up having to bump the version of azurerm up to a newer version (despite not having changed this version in months).

lonegunmanb commented 2 years ago

Hello @rohith267 , how're things going? Do you need any extra help to reproduce this issue?

rohith267 commented 2 years ago

Hi @lonegunmanb , we are unable to reproduce the issue with the sample code (by creating a app service plan and azure function app). But we are facing the issue with our actual code. We faced the same issue of plugin not responding with azurerm provider version 3.1.0 also. But we are unable to reproduce the issue with the sample code. So, we didn't upgrade the resources (azurerm_app_service_plan to azurerm_service_plan and azurerm_function_app to azurerm_windows_function_app ) and just upgraded the azurerm provider version and made minimum changes required, for now.

lonegunmanb commented 2 years ago

Hi @rohith267, copy that, I'll see what I can do.

lonegunmanb commented 2 years ago

Hi @rohith267 , unfortunately I cannot reproduce this panic either. According to the stack trace, the panic occurred before azurerm_windows_function_app's creation function's call. And it seems like you're trying to create a new windows function app right?

rohith267 commented 2 years ago

@lonegunmanb we already have resources azurerm_function_app in previous 2.x versions. As these resources will get deprecated in 4.x versions, so we tried to upgrade it to azurerm_windows_function_app and upgrade azurerm provider version to 3.0.2. Then we found this error.