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.59k stars 4.63k forks source link

no schema available for azurerm_dashboard. out of terraform plan for azurerm_portal_dashboard #27198

Closed MarcusGasser closed 1 month ago

MarcusGasser commented 2 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.9.5

AzureRM Provider Version

4.0.1

Affected Resource(s)/Data Source(s)

azurerm_portal_dashboard

Terraform Configuration Files

locals {
  
  dashboards_base_path = "json-templates/dashboards/%s"

}



resource "azurerm_portal_dashboard" "entrypoint_dashboard" {
  
  name                = "entrypoint_dashboard"
  
  resource_group_name = azurerm_resource_group.cos_workbooks_rg.name

  location            = var.location
  
  tags = {
    
    "hidden-title" : "Entrypoint Dashboard"
  
  }
  
  dashboard_properties = file(format(local.dashboards_base_path, "entrypoint-dashboard.json"))

}

Debug Output/Panic Output

Terraform planned the following actions, but then encountered a problem:
  # azurerm_portal_dashboard.entrypoint_dashboard will be created
  + resource "azurerm_portal_dashboard" "entrypoint_dashboard" {
      + dashboard_properties = jsonencode(
            {
              + lenses   = {
                  + "0" = {
                      + order = 0
                      + parts = {
                          + "0" = {
                              + metadata = {
                                  + inputs   = []
                                  + settings = {
                                      + content = {
                                          + content        = <<-EOT
                                                # ... dashboard code
                                                </div>
                                            EOT
                                          + markdownSource = 1
                                          + markdownUri    = ""
                                          + subtitle       = ""
                                          + title          = ""
                                        }
                                    }
                                  + type     = "Extension/HubsExtension/PartType/MarkdownPart"
                                }
                              + position = {
                                  + colSpan = 10
                                  + rowSpan = 7
                                  + x       = 0
                                  + y       = 0
                                }
                            }
                        }
                    }
                }
              + metadata = {
                  + model = {
                      + timeRange = {
                          + type  = "MsPortalFx.Composition.Configuration.ValueTypes.TimeRange"
                          + value = {
                              + relative = {
                                  + duration = 24
                                  + timeUnit = 1
                                }
                            }
                        }
                    }
                }
            }
        )
      + id                   = (known after apply)
      + location             = "switzerlandnorth"
      + name                 = "entrypoint_dashboard"
      + resource_group_name  = "cos-workbooks-iac-preprod-rg"
      + tags                 = {
          + "hidden-title" = "Entrypoint Dashboard"
        }
    }
Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Error: no schema available for azurerm_dashboard.entrypoint_dashboard while reading state; this is a bug in Terraform and should be reported
│

Expected Behaviour

should end with exit code 0

Actual Behaviour

│ Error: no schema available for azurerm_dashboard.entrypoint_dashboard while reading state; this is a bug in Terraform and should be reported

Steps to Reproduce

terraform plan

Important Factoids

No response

References

No response

hqhqhqhqhqhqhqhqhqhqhq commented 1 month ago

Hi @MarcusGasser , thanks for raising this.

I believe the issue it that the resource was originally named as azurerm_dashboard and got renamed to azurerm_portal_dashboard in v4.0. The azurerm_dashboard exist in your state file, that is why terraform error during reading it from the state.

To address this, you can:

  1. Backup your state in case anything goes wrong
  2. Remove azurerm_dashboard from the state file via terraform state rm azurerm_dashboard.entrypoint_dashboard
  3. Make the changes in your config
  4. Import those the resource back to state via terraform import azurerm_portal_dashboard.entrypoint_dashboard <resource id>
MarcusGasser commented 1 month ago

Thak you so much, worked for me!

github-actions[bot] commented 1 week 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.