Introduction
This Knowledge Base article provides a solution for a common issue encountered when using Terraform with the azurerm provider. Users may encounter the error message:
subscription_id is a required provider property when performing a plan/apply operation.
This guide outlines why this error occurs, its root causes, and how to resolve it quickly.
Problem
Users running terraform plan or terraform apply with the Azure Provider (azurerm) may encounter the following error:
│ Error: `subscription_id` is a required provider property when performing a plan/apply operation
│
│ with provider["registry.terraform.io/hashicorp/azurerm"],
│ on providers.tf line 7, in provider "azurerm":
│ 7: provider "azurerm" {
This error blocks deployment and must be resolved to continue provisioning infrastructure via Terraform.
Prerequisites
This issue applies to:
• Terraform using the azurerm provider
• azurerm provider version >= 4.0
• Azure as the cloud provider
Cause
This error is typically caused by an update introduced in version 4.0 of the azurerm provider. In this version:
• It became mandatory to explicitly set the subscription_id in the provider block.
You may encounter this error under the following conditions:
1. You recently upgraded to azurerm provider version 4.0 or later.
2. Your provider block does not specify a subscription_id.
3. You expected the subscription_id to be inferred from environment variables or CLI authentication.
Overview of possible solutions
You can resolve this issue by explicitly adding the required subscription_id in your provider block. This ensures compatibility with the new requirement introduced in azurerm 4.0.
Solution : Add subscription_id to provider block
Update your provider "azurerm" block to include your Azure Subscription ID.
provider "azurerm" {
features {}
subscription_id = "0000000-0000-0000-0000-000000000000" # Replace with your actual subscription ID
}
Outcome
After applying the fix and running terraform init, try running terraform plan or terraform apply again. If the error no longer appears and Terraform continues to execute your plan, the issue is resolved.
If the issue persists:
• Double-check that the subscription ID is valid and correctly entered.
• Ensure you are using the correct azurerm provider version (terraform providers can help confirm).
• Review the provider documentation for additional changes in version 4.0.
Additional Information