Problem
When running terraform init, you may encounter the following error, indicating a mismatch between the provider plugin's API version and the Terraform CLI's supported version.
Error: provider.external: Incompatible API version with plugin. Plugin version: 5, Core version: 4
Cause
This error occurs because the version of the provider plugin being installed requires a newer Terraform Protocol version than the installed Terraform CLI version supports. Provider plugins released after a specific Terraform CLI version may not be compatible with older Terraform CLI binaries.
Solutions
There are two primary solutions to resolve this incompatibility. The recommended approach is to upgrade the Terraform CLI, but constraining the provider version is also a viable temporary alternative.
Solution 1: Upgrade the Terraform CLI
The recommended solution is to upgrade your Terraform CLI to a more recent version that is compatible with the newer provider plugin. This ensures you have the latest features and security updates.
For detailed instructions, refer to the official Terraform documentation on upgrading the Terraform CLI.
Solution 2: Constrain the Provider Version
As a temporary alternative, you can constrain the provider version in your configuration to use an older version that is compatible with your current Terraform CLI.
Add a version constraint for the provider in your Terraform configuration file, for example
main.tf.terraform { required_providers { external = { source = "hashicorp/external" version = "< 2.1.0" } } }Note: The example uses the
externalprovider. Adjust the provider name and version constraint to match your specific needs. The< 2.1.0constraint ensures Terraform selects a version of the external provider older than 2.1.0, which is compatible with Terraform Protocol version 4.Run the
terraform initcommand to re-initialize your working directory with the specified provider version.$ terraform init
Additional Information
- For more details on provider version constraints, please see the provider requirements documentation.