-1

When I was trying to provision my Azure resources via running the Terraform script in Azure DevOps pipelines, I encountered the following error:

│ Error: Provider configuration not present
│ 
│ To work with
│ module.xxxxxxxxx its
│ original provider configuration at
│ module.xxxxxx.provider["registry.terraform.io/hashicorp/azurerm"].some_name
│ is required, but it has been removed. This occurs when a provider
│ configuration is removed while objects created by that provider still exist
│ in the state. Re-add the provider configuration to destroy
│ module.xxxxxxxxx, after
│ which you can remove the provider configuration again.

I don't understand why even I deleted the state file from the Azure storage account, it still fails.

Appreciate for any solutions.

9
  • "I don't understand why even I deleted the state file from the Azure storage account, it still fails" - double-check if you removed the right state file. Commented Nov 6, 2024 at 10:25
  • @Rui Jarimba, thank you for your reply. I am sure that I do delete the right state file. Commented Nov 6, 2024 at 10:32
  • HAve you verified the azure service connection is given properly. @akaya_1992 Commented Nov 6, 2024 at 10:32
  • Also check this blog once on configuration part if you missed anything. @akaya_1992 Commented Nov 6, 2024 at 10:40
  • @Jahnavi, yes, I think so. I did try to use the same set of script before. It just suddenly not working anymore. Commented Nov 6, 2024 at 13:17

1 Answer 1

0

Provider configuration not present issue terraform

In error it was clearly mentioned as per the description you tried to remove the provider from the configuration which you used to provision the resources.

Which means you creating some resources using a provider which is updated in state file. Now later on you removed the same provider block you used to provision from the configuration and its not reflected in statefile since youre getting the error while executing commands. Now after removing the provider configuration, you try to make some changes or delete in the rest of the resource configuration that are provisioned using that provider without provider block present in the configuration which will make you end blocker missing provider configuration.

Even you removed the entire statefile sometimes it doesn’t necessarily remove all references to the provider configuration, especially if there are dependent resources that still exist in the cloud

We can do two things here

  • Try deleting the resources that are present under azure and run it again from terrafrom init .
  • Include the provider configuration that you used while provisioning the resource.

configuration:

terraform {
  backend "azurerm" {
    resource_group_name   = "example-rg"
    storage_account_name  = "examplestorageacc"
    container_name        = "tfstate"
    key                   = "terraform.tfstate"
  }
}


provider "azurerm" {
  features {}
}

Refer:

GitHub - hashicorp/terraform-provider-azurerm: Terraform provider for Azure Resource Manager

Backend Type: azurerm | Terraform | HashiCorp Developer

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.