This error occurs when Terraform encounters a resource type it doesn't recognize. Common causes include missing provider configuration, typos in resource type names, or using an unsupported resource type with the current provider version.
The 'Invalid resource type' error means Terraform cannot find the resource type you're trying to use in any of the configured providers. This happens when a resource type is referenced in your configuration but either the provider that supports it isn't configured, the provider hasn't been initialized, or the resource type name is misspelled. Terraform validates the configuration during the init or plan phase and reports unknown resource types before attempting to create any infrastructure.
Verify that the resource type in your configuration exactly matches the provider documentation. Resource types follow the pattern: 'provider_resource'.
# Wrong - typo in resource type
resource "aws_instace" "example" {
# configuration...
}
# Correct
resource "aws_instance" "example" {
# configuration...
}Common typos:
- 'aws_instace' instead of 'aws_instance'
- 'azurem_resource_group' instead of 'azurerm_resource_group'
- 'gcp_compute_instance' instead of 'google_compute_instance'
Check the official Terraform Registry documentation for the correct resource type name for your provider.
Add the provider to your required_providers block in the terraform configuration:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}For custom or third-party providers, use the full source path:
terraform {
required_providers {
custom = {
source = "example.com/custom/provider"
version = "1.0.0"
}
}
}Then add the provider configuration block:
provider "aws" {
region = "us-east-1"
}Initialize your Terraform working directory to download and install the required provider plugins:
terraform initThis command reads the required_providers block and downloads the specified provider versions. If you see 'provider not found', ensure your source URL is correct and accessible.
If using a private registry or custom provider:
terraform init -upgradeThis forces Terraform to re-evaluate and download the latest available versions of providers.
After running terraform init, check that the correct provider was downloaded:
terraform providersThis shows all installed providers. If the expected provider is missing, check:
- The source URL in required_providers is correct
- You have network access to the provider registry
- The provider version constraints allow at least one version to be downloaded
View the full provider documentation:
terraform providers showFor official HashiCorp providers, visit https://registry.terraform.io to verify the correct source path and available resource types.
Some resource types are only available in newer versions of providers. Check when the resource was added:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0" # Adjust version if resource is new
}
}
}If the resource type was recently added to the provider, increase the version constraint. Check the provider's CHANGELOG or documentation to see when the resource became available.
To update a provider to its latest version:
terraform init -upgradeFor custom providers or private registries, ensure your Terraform CLI is configured with the correct credentials and provider configuration in your local .terraformrc file (or in TF_CLI_CONFIG_FILE environment variable). If using Terraform Cloud or Enterprise, verify that the provider is available in your private registry. When migrating between provider versions, note that some resources may be deprecated or renamed - check the migration guide in the provider documentation. For plugin framework-based providers (newer pattern), cache configuration may temporarily hide resources; clear your plugin cache with 'rm -rf .terraform/plugins' and rerun 'terraform init' if needed.
Error: Error installing helm release: cannot re-use a name that is still in use
How to fix "release name in use" error in Terraform with Helm
Error: Error creating GKE Cluster: BadRequest
BadRequest error creating GKE cluster in Terraform
Error: External program failed to produce valid JSON
External program failed to produce valid JSON
Error: Unsupported argument in child module call
How to fix "Unsupported argument in child module call" in Terraform
Error: network is unreachable
How to fix "network is unreachable" in Terraform