How to fix Error: Invalid resource type in Terraform
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.
Quick fix
Fixes Error: Invalid resource type
# Wrong - typo in resource type
resource "aws_instace" "example" {
# configuration...
}
# Correct
resource "aws_instance" "example" {
# configuration...
}- Check the resource type spelling and syntax
- Ensure the required provider is declared
- Run terraform init to download providers
- Verify the provider source and version
# Wrong - typo in resource typeresource "aws_instace" "example" {# configuration...}# Correctresource "aws_instance" "example" {# configuration...}Error: Invalid resource type
What this error means
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.
Typical symptoms
- Terraform plan or apply fails with 'invalid resource type' error
- Error message specifies an unknown resource type like 'aws_instace' or similar
- Configuration file contains a resource block with an unrecognized type
- Error occurs during 'terraform init' or 'terraform plan'
- Provider plugins are not available or not initialized
Common causes
- Typo in resource type name (e.g., 'aws_instace' instead of 'aws_instance')
- Required provider is not declared in the required_providers block
- Provider has not been initialized with 'terraform init'
- Using an incorrect provider prefix (e.g., 'azure_' instead of 'azurerm_')
- Resource type doesn't exist in the configured provider version
- Custom or third-party provider not properly sourced or referenced
How to fix "Error: Invalid resource type"
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 -upgradeAdvanced notes
For 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.
Frequently asked questions
- What does "Error: Invalid resource type" mean?
- 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.
- How do I fix "Error: Invalid resource type"?
- 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.
- What causes "Error: Invalid resource type"?
- Typo in resource type name (e.g., 'aws_instace' instead of 'aws_instance') Required provider is not declared in the required_providers block Provider has not been initialized with 'terraform init'
- Is the "Error: Invalid resource type" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐Terraform Official Documentation
- ๐Terraform Troubleshooting Workflow(Official Docs)
- ๐Terraform Provider Requirements(Official Docs)
- ๐Terraform Registry - Find Resource Types(Official Docs)
- ๐