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.52k stars 4.6k forks source link

Error: The terraform-provider-azurerm_v3.75.0_x5 plugin crashed #23452

Open bradenrichardson opened 11 months ago

bradenrichardson commented 11 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.5.6

AzureRM Provider Version

3.75.0

Affected Resource(s)/Data Source(s)

azurerm_windows_web_app

Terraform Configuration Files

# Resources to be shared (eg ACR)
resource "azurerm_resource_group" "app-hub" {
  name     = "app-hub"
  location = "australiaeast"
}

resource "random_integer" "ri" {
  min = 1000
  max = 99999
}

resource "azurerm_resource_group" "alpha-web-app" {
  name     = "alpha-web-app"
  location = "australiaeast"
}

resource "azurerm_container_registry" "registry" {
  name                = "${random_integer.ri.result}containerregistry"
  resource_group_name = azurerm_resource_group.app-hub.name
  location            = azurerm_resource_group.app-hub.location
  sku                 = "Standard"
  admin_enabled       = true # required for App Service
}

resource "azurerm_service_plan" "alpha-web-app" {
  name                = "alpha-service-plan"
  location            = azurerm_resource_group.alpha-web-app.location
  resource_group_name = azurerm_resource_group.alpha-web-app.name
  os_type             = "WindowsContainer"
  sku_name            = "P1v3"
}

resource "azurerm_windows_web_app" "alpha-web-appv2" {
  depends_on          = [azurerm_service_plan.alpha-web-app]
  name                = "alpha-web-appv2"
  location            = azurerm_resource_group.alpha-web-app.location
  resource_group_name = azurerm_resource_group.alpha-web-app.name
  service_plan_id     = azurerm_service_plan.alpha-web-app.id
  site_config {
    application_stack {
      current_stack            = "dotnetcore"
      docker_image_name        = "azure-app-service/windows/alpha:latest"
      docker_registry_url      = "https://${azurerm_container_registry.registry.login_server}"
      docker_registry_username = azurerm_container_registry.registry.admin_username
      docker_registry_password = azurerm_container_registry.registry.admin_password
    }
  }
  identity {
    type = "SystemAssigned"
  }

}

resource "azurerm_role_assignment" "acr_pull" {
  depends_on                       = [azurerm_windows_web_app.alpha-web-app]
  principal_id                     = azurerm_windows_web_app.alpha-web-app.identity[0].principal_id
  role_definition_name             = "AcrPull"
  scope                            = azurerm_container_registry.registry.id
  skip_service_principal_aad_check = true
}

Debug Output/Panic Output

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

panic: assignment to entry in nil map

goroutine 268 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers.(*SiteConfigWindows).ExpandForCreate(0xc005206af8, 0x0)
github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers/windows_web_app_schema.go:528 +0xfe8
github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice.WindowsWebAppResource.Create.func1({0x7ad1ee8, 0xc0051c3dd0}, {0xc000eae480, {0x7ad27a8, 0xc0003ff5d8}, 0xc001b89680, 0x0, {0x7ad38f0, 0xc520898}})
github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/windows_web_app_resource.go:332 +0xe10
github.com/hashicorp/terraform-provider-azurerm/internal/sdk.(*ResourceWrapper).Resource.func2({0x7ad1ee8, 0xc0051c3dd0}, 0x7ad1f20?, {0x650c720?, 0xc000eae480?})
github.com/hashicorp/terraform-provider-azurerm/internal/sdk/wrapper_resource.go:55 +0x163
github.com/hashicorp/terraform-provider-azurerm/internal/sdk.diagnosticsWrapper.func1({0x7ad1ee8, 0xc0051c3dd0}, 0x0?, {0x650c720, 0xc000eae480})
github.com/hashicorp/terraform-provider-azurerm/internal/sdk/wrapper_resource.go:190 +0xb8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc000282fc0, {0x7ad1f20, 0xc004dd33e0}, 0xd?, {0x650c720, 0xc000eae480})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:778 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000282fc0, {0x7ad1f20, 0xc004dd33e0}, 0xc0051029c0, 0xc001b89500, {0x650c720, 0xc000eae480})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:909 +0xa7e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc001611068, {0x7ad1f20?, 0xc004dd32c0?}, 0xc000fc7bd0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:1060 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc001631720, {0x7ad1f20?, 0xc004dd2ab0?}, 0xc000831030)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:859 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x6f38840?, 0xc001631720}, {0x7ad1f20, 0xc004dd2ab0}, 0xc000830f50, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001d61e0, {0x7ae2b20, 0xc000fe3ba0}, 0xc004ce17a0, 0xc00148c0c0, 0xc4df498, 0x0)
google.golang.org/grpc@v1.58.0/server.go:1376 +0xdd2
google.golang.org/grpc.(*Server).handleStream(0xc0001d61e0, {0x7ae2b20, 0xc000fe3ba0}, 0xc004ce17a0, 0x0)
google.golang.org/grpc@v1.58.0/server.go:1753 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/grpc@v1.58.0/server.go:998 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.58.0/server.go:996 +0x18c

Error: The terraform-provider-azurerm_v3.75.0_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

Plan should have succeeded or at least errored out with a standard message

Actual Behaviour

The plugin crashed

Steps to Reproduce

Trigger plan + apply in Terraform Cloud

Important Factoids

No response

References

No response

iofh commented 11 months ago

Having the same issue with our terraform too.

Not a fix but a workaround

Using the old way it works.

docker_container_name    = "azure-app-service/samples/aspnethelloworld"
docker_container_registry = "mcr.microsoft.com"
docker_container_tag = "latest"

and modifying the old way to the new way doesnt seem to break the terraform plan.