hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.33k stars 9.49k forks source link

azurerm_mssql_elasticpool Failed to Destroy #33369

Closed Denisjc closed 1 year ago

Denisjc commented 1 year ago

Terraform Version

Terraform v1.5.0
on windows_386
+ provider registry.terraform.io/hashicorp/azurerm v3.61.0
+ provider registry.terraform.io/hashicorp/random v3.5.1

Terraform Configuration Files

create_database.tf

resource "azurerm_mssql_elasticpool" "pool" {
  name                = var.db_elastic_pool
  resource_group_name = azurerm_resource_group.devx.name
  location            = azurerm_resource_group.devx.location
  server_name         = azurerm_mssql_server.server.name
  max_size_gb         = 50

  sku {
    name     = "StandardPool"
    tier     = "Standard"
    capacity = 100
  }

  per_database_settings {
    min_capacity = 50
    max_capacity = 100
  }

  tags = merge(local.tags, {
  })
}

terraform.tfstate

 {
      "mode": "managed",
      "type": "azurerm_mssql_elasticpool",
      "name": "pool",
      "provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "id": "/subscriptions/f4a675bc-b98b-453c-bf43-e2f3654fb899/resourceGroups/asdevxeuneuais001rg001/providers/Microsoft.Sql/servers/asdeveuneuais001sqlsrv003/elasticPools/asdeveuneuais001pool001",
            "license_type": "",
            "location": "northeurope",
            "maintenance_configuration_name": "SQL_Default",
            "max_size_bytes": 53687091200,
            "max_size_gb": 50,
            "name": "asdeveuneuais001pool001",
            "per_database_settings": [
              {
                "max_capacity": 100,
                "min_capacity": 50
              }
            ],
            "resource_group_name": "asdevxeuneuais001rg001",
            "server_name": "asdeveuneuais001sqlsrv003",
            "sku": [
              {
                "capacity": 100,
                "family": "",
                "name": "StandardPool",
                "tier": "Standard"
              }
            ],
            "tags": {
              "Application Name": "AIS",
              "Environment": "DevX",
              "Source": "terraform"
            },
            "timeouts": null,
            "zone_redundant": false
          },
          "sensitive_attributes": [],
          "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjE4MDAwMDAwMDAwMDAsInJlYWQiOjMwMDAwMDAwMDAwMCwidXBkYXRlIjoxODAwMDAwMDAwMDAwfX0=",
          "dependencies": [
            "azurerm_mssql_server.server",
            "azurerm_resource_group.devx",
            "random_password.admin_password"
          ]
        }
      ]
    },

Debug Output

azurerm_resource_group.devx: Refreshing state... [id=/subscriptions/f4a675bc-b98b-453c-bf43-e2f3654fb899/resourceGroups/asdevxeuneuais001rg001] azurerm_mssql_server.server: Refreshing state... [id=/subscriptions/f4a675bc-b98b-453c-bf43-e2f3654fb899/resourceGroups/asdevxeuneuais001rg001/providers/Microsoft.Sql/servers/asdeveuneuais001sqlsrv003] azurerm_mssql_elasticpool.pool: Refreshing state... [id=/subscriptions/f4a675bc-b98b-453c-bf43-e2f3654fb899/resourceGroups/asdevxeuneuais001rg001/providers/Microsoft.Sql/servers/asdeveuneuais001sqlsrv003/eazurerm_mssql_database.dwh1_serverless: Refreshing state... [id=/subscriptions/f4a675bc-b98b-453c-bf43-e2f3654fb899/resourceGroups/asdevxeuneuais001rg001/providers/Microsoft.Sql/servers/asdeveuneuais001sqlsrv003/databases/asdeveuneuais001sqldb002] ╷ │ Error: Plugin did not respond │ │ with azurerm_mssql_database.dwh1_serverless, │ on create_database.tf line 14, in resource "azurerm_mssql_database" "dwh1_serverless": │ 14: resource "azurerm_mssql_database" "dwh1_serverless" { │ │ 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 azurerm_mssql_elasticpool.pool, │ on create_database_server.tf line 28, in resource "azurerm_mssql_elasticpool" "pool": │ 28: resource "azurerm_mssql_elasticpool" "pool" { │ │ The plugin encountered an error, and failed to respond to the plugin.(GRPCProvider).ReadResource call. The plugin logs may contain more details. ╵

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

panic: Error reading level state: strconv.ParseInt: parsing "53687091200": value out of range

goroutine 248 [running]: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(ResourceData).get(0x1e211b80, {0x1e3251b8, 0x1, 0x1}, 0x8) github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource_data.go:553 +0x279 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(ResourceData).State(0x1e211b80) github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource_data.go:351 +0x3a7 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).ShimInstanceStateFromValue(0x1ce5d8f0, {{{0x77f8400, 0x1e324960}}, {0x64d8aa0, 0x1e267f80}}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:599 +0x1d9 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ReadResource(0x1cc085a0, {0x77f75e0, 0x1dd66cf0}, 0x1e2679e0) github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/grpc_provider.go:587 +0x23f github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(server).ReadResource(0x1ce2b5e0, {0x77f75e0, 0x1dd66600}, 0x1e26e630) github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:748 +0x4c5 github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x6bd82e0, 0x1ce2b5e0}, {0x77f75e0, 0x1dd66600}, 0x1daae400, 0x0) github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x18a google.golang.org/grpc.(Server).processUnaryRPC(0x1cf1c6c0, {0x7800084, 0x1d9d4000}, 0x1e30ae60, 0x1dfd8f60, 0xbb9b448, 0x0) google.golang.org/grpc@v1.51.0/server.go:1340 +0xe22 google.golang.org/grpc.(Server).handleStream(0x1cf1c6c0, {0x7800084, 0x1d9d4000}, 0x1e30ae60, 0x0) google.golang.org/grpc@v1.51.0/server.go:1713 +0xa17 google.golang.org/grpc.(Server).serveStreams.func1.2() google.golang.org/grpc@v1.51.0/server.go:965 +0xb1 created by google.golang.org/grpc.(*Server).serveStreams.func1 google.golang.org/grpc@v1.51.0/server.go:963 +0x25f

Error: The terraform-provider-azurerm_v3.61.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 Behavior

The items should have been deleted.

Actual Behavior

The state file was updated and the plugin now fails to run terraform plan -out main.tfplan Or terraform plan -destroy -out main.tfplan

Editing the state file and removing the setting returns the state to allow plan to to work, but destory seems to return the value back to the state file.

Steps to Reproduce

  1. terraform plan -out main.tfplan
  2. terraform plan -destroy -out main.tfplan

At this point the terraform.tfstate state file contrains the value 53687091200

"max_size_bytes": 53687091200,

changing this to a smaller value allows for the terraform plan -out main.tfplan to work again but not the terraform plan -destroy -out main.tfplan

Thus I cannot delete the pool from terraform.

Additional Context

No response

References

No response

jbardin commented 1 year ago

Hello,

This appears to be an issue or question with the AzureRM provider, not with Terraform itself. You can see existing issues and file a new one in their repository here: https://github.com/terraform-providers/terraform-provider-azurerm/issues. If you have questions about Terraform or the AzureRM provider, it's better to use the community forum where there are more people ready to help. The GitHub issues here are monitored only by a few core maintainers.

Thanks!

Denisjc commented 1 year ago

cool have raised an error on that forum - New Ticket on Plugin Forum

github-actions[bot] commented 9 months ago

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.