Skip to content

Terraform Error: Error: Failed to load plugin schemas while running Terraform for azure #33827

Description

@aviksamanta1986

Terraform Version

1.5.6

Terraform Configuration Files

terraform {
  required_version = "~> 1.5.6"
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "~> 3.50.0"
    }
  }
  backend "azurerm" {} #Backend variables are initialized through the secret and variable folders
}

provider "azurerm" {
  #version         = "~> 3.50.0"
  tenant_id       = var.tenant_id
  subscription_id = var.subscription_id

  features {}
}

Debug Output

2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_key_vault_key.this
2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_windows_virtual_machine.windows_vms
2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_network_interface.windows_nics
2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_virtual_machine_data_disk_attachment.this
2023-09-06T19:57:41.714Z [TRACE] terraform.contextPlugins: Initializing provider "terraform.io/builtin/terraform" to read its schema
2023-09-06T19:57:41.714Z [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_backup_protected_vm.this
2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_key_vault_secret.this
2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching resource schema to data.terraform_remote_state.loadbalancer
2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching resource schema to data.terraform_remote_state.applicationsecuritygroup
2023-09-06T19:57:41.714Z [TRACE] AttachSchemaTransformer: attaching provider config schema to provider["registry.terraform.io/hashicorp/azurerm"]

2023-09-06T19:57:42.582Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_key_vault_access_policy.this (expand)
2023-09-06T19:57:42.582Z [TRACE] AttachSchemaTransformer: attaching resource schema to data.azurerm_backup_policy_vm.this (expand)
2023-09-06T19:57:42.582Z [TRACE] AttachSchemaTransformer: attaching resource schema to data.terraform_remote_state.storage (expand)
2023-09-06T19:57:42.582Z [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
2023-09-06T19:57:42.582Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_key_vault_key.this (expand)
2023-09-06T19:57:42.582Z [TRACE] AttachSchemaTransformer: attaching resource schema to azurerm_disk_encryption_set.this (expand)

Expected Behavior

Terraform plan should have worked.

Actual Behavior

Error: Failed to load plugin schemas

│ Error while loading schemas for plugin components: Failed to obtain
│ provider schema: Could not load the schema for provider
│ registry.terraform.io/-/azurerm: failed to instantiate provider
│ "registry.terraform.io/-/azurerm" to obtain schema: unavailable provider
│ "registry.terraform.io/-/azurerm"..


│ Error: Failed to load plugin schemas

│ Error while loading schemas for plugin components: Failed to obtain
│ provider schema: Could not load the schema for provider
│ registry.terraform.io/-/azurerm: failed to instantiate provider
│ "registry.terraform.io/-/azurerm" to obtain schema: unavailable provider
│ "registry.terraform.io/-/azurerm"..


│ Error: Failed to load plugin schemas

│ Error while loading schemas for plugin components: 2 problems:

│ - Failed to obtain provider schema: Could not load the schema for provider
│ registry.terraform.io/-/azurerm: failed to instantiate provider
│ "registry.terraform.io/-/azurerm" to obtain schema: unavailable provider
│ "registry.terraform.io/-/azurerm".
│ - Failed to obtain provider schema: Could not load the schema for provider
│ registry.terraform.io/-/random: failed to instantiate provider
│ "registry.terraform.io/-/random" to obtain schema: unavailable provider
│ "registry.terraform.io/-/random"..

Steps to Reproduce

  1. Terraform Init -upgrade
  2. Terraform plan

The resources were initially deployed using 0.12 and provider version 2.20. I upgraded the code to 1.X by rewriting the code. The backend is azure storage container.

Additional Context

I am running terraform plan through Azure pipelines for windows virtual machine. We had previously created the VM and all related resources in terrform 0.12 and AzureRM 2.20. I have upgraded the code to 1.5.6. When running the terrform init with upgrade option, the initialization is a success, but, the plan fails. The code basically uses the azure keyvault to store a customer managed key and uses that for the managed disk for the windows virtual machine. We are trying to upgrade terraform provider versions to use key rotation. The random module is used to generate VM password.
I have verified that the downloaded plugins have execute privileges after terraform init.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions