Terraform Error Guide: 'Invalid resource type' — Fix Missing or Wrong Provider
Fix Terraform 'Invalid resource type' errors: correct the resource name, add or pin the right provider in required_providers, run terraform init, and align provider versions.
- #terraform
- #iac
- #troubleshooting
- #errors
Fixing errors like this? Get 500 free DevOps AI prompts
500 copy-paste AI prompts for the stack you actually run — one PDF, free.
Overview
Terraform raises this error during validate, plan, or apply when a resource block names a type that the configured provider does not offer. The type looks plausible but does not exist, is spelled wrong, belongs to a provider that was never required, or was added in a newer provider version than the one you have locked.
Error: Invalid resource type
on main.tf line 12, in resource "aws_s3_buckett" "assets":
12: resource "aws_s3_buckett" "assets" {
The provider hashicorp/aws does not support resource type "aws_s3_buckett".
The prefix before the first underscore (aws, google, azurerm) selects the provider; the rest names the resource. If either half is wrong, or the provider is absent, Terraform cannot map the block to a real schema and stops before touching any infrastructure.
Symptoms
terraform validateorterraform planfails immediately withInvalid resource typeand points at a specificresourceline.- The message ends with
The provider <namespace>/<name> does not support resource type "<type>". - A brand-new resource type works locally for a teammate but fails for you, hinting at a provider-version mismatch.
- Copy-pasted example code fails because it assumes a provider you never declared in
required_providers. - A resource that used to plan cleanly breaks after a provider downgrade or a lock-file rollback.
Common Root Causes
- Typo in the resource type —
aws_s3_buckett,google_compute_instace, transposed characters, or a wrong plural/singular. - Provider not declared or not installed — the type belongs to a provider missing from
required_providers, soterraform initnever fetched it. - Provider version too old — the resource exists only in a newer provider release than the one pinned in
.terraform.lock.hcl. - Wrong provider namespace — a community fork or a different namespace than
hashicorp/*supplies the resource, and the source is not set correctly. - Renamed or removed resource — the provider renamed the type across a major version, so the old name no longer resolves.
- Data source vs resource confusion — the name exists only as a
datasource, not aresource(or vice versa).
Diagnostic Workflow
Start by confirming the exact type and provider the block resolves to:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.60"
}
}
}
resource "aws_s3_bucket" "assets" {
bucket = "example-assets"
}
Check which providers are actually installed and at what versions:
terraform providers
terraform version
terraform providers schema -json | jq '.provider_schemas | keys'
Confirm the specific type is present in the installed provider’s schema (this lists real resource types the provider offers):
terraform providers schema -json \
| jq '.provider_schemas["registry.terraform.io/hashicorp/aws"].resource_schemas | keys[]' \
| grep -i s3_bucket
If the provider is missing or the wrong version is locked, re-initialize and upgrade:
terraform init -upgrade
Cross-check the resource name and the minimum provider version against the registry documentation for that exact type before changing code.
Example Root Cause Analysis
A team added an aws_s3_bucket_lifecycle_configuration resource and CI failed with Invalid resource type even though the code was correct.
Running terraform version in CI showed AWS provider v3.74, while the author had v5.60 locally. The lifecycle-configuration resource was introduced in the AWS provider 4.x line, so the older locked provider had no such type in its schema.
The fix was to bump the constraint to ~> 5.0 in required_providers, commit the regenerated .terraform.lock.hcl, and run terraform init -upgrade in CI. Once every environment resolved the same provider version, the resource type resolved and the plan succeeded. The underlying lesson: Invalid resource type is often a version-skew symptom, not a typo.
Prevention Best Practices
- Pin providers with a sensible constraint (
~> 5.60) inrequired_providersand commit.terraform.lock.hclso every environment resolves the same schema. - Run
terraform init -upgradeand commit the lock file as a deliberate step when adopting a newer resource type. - Enable editor/LSP support (terraform-ls) so unknown resource types surface before commit.
- Add
terraform validateto CI and pre-commit soInvalid resource typefails fast, close to the author. - When copying examples, copy the accompanying
required_providersblock and confirm the source namespace, not just the resource body. - Read the registry docs for the minimum provider version whenever a resource type is new.
Quick Command Reference
terraform validate # catch invalid types early
terraform providers # list required/installed providers
terraform version # core + provider versions
terraform init -upgrade # fetch newer provider that has the type
terraform providers schema -json | jq '.provider_schemas | keys'
Conclusion
Invalid resource type means Terraform could not map a resource block to any type the configured provider exposes — almost always a typo, a missing/mis-declared provider, or a provider version too old to include the type. Verify the exact name against the provider schema, ensure the right provider and version are declared and initialized, and commit the lock file so the whole team resolves the same schema. Fixing the version skew, not just the spelling, is what keeps the error from returning in CI.
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.