How to fix Error: Invalid resource type in Terraform

TerraformBEGINNERHIGHUpdated Dec 30, 2025ยท 97 views

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...
}
  1. Check the resource type spelling and syntax
  2. Ensure the required provider is declared
  3. Run terraform init to download providers
  4. Verify the provider source and version
terraform โ€” error
# Wrong - typo in resource type
resource "aws_instace" "example" {
# configuration...
}
# Correct
resource "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

  1. Typo in resource type name (e.g., 'aws_instace' instead of 'aws_instance')
  2. Required provider is not declared in the required_providers block
  3. Provider has not been initialized with 'terraform init'
  4. Using an incorrect provider prefix (e.g., 'azure_' instead of 'azurerm_')
  5. Resource type doesn't exist in the configured provider version
  6. Custom or third-party provider not properly sourced or referenced

How to fix "Error: Invalid resource type"

1Check the resource type spelling and syntax

Verify that the resource type in your configuration exactly matches the provider documentation. Resource types follow the pattern: 'provider_resource'.

hcl
# 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.

2Ensure the required provider is declared

Add the provider to your required_providers block in the terraform configuration:

hcl
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

For custom or third-party providers, use the full source path:

hcl
terraform {
  required_providers {
    custom = {
      source  = "example.com/custom/provider"
      version = "1.0.0"
    }
  }
}

Then add the provider configuration block:

hcl
provider "aws" {
  region = "us-east-1"
}
3Run terraform init to download providers

Initialize your Terraform working directory to download and install the required provider plugins:

bash
terraform init

This 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:

bash
terraform init -upgrade

This forces Terraform to re-evaluate and download the latest available versions of providers.

4Verify the provider source and version

After running terraform init, check that the correct provider was downloaded:

bash
terraform providers

This 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:

bash
terraform providers show

For official HashiCorp providers, visit https://registry.terraform.io to verify the correct source path and available resource types.

5Check provider version supports the resource

Some resource types are only available in newer versions of providers. Check when the resource was added:

hcl
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:

bash
terraform init -upgrade

Advanced 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