Quick Answer
# Upgrade provider to match state
terraform init -upgrade
The Error
Error: Resource instance managed by newer provider version
The current state of aws_instance.web was created by a newer provider version
than is currently selected. Upgrade the hashicorp/aws provider to work with
this resource.
Current version: 5.40.0
Required version: >= 5.60.0
Or:
Error: state snapshot was created by Terraform v1.9.0, which is newer than
current v1.7.0
What Causes This
- Team member upgraded — someone ran with a newer provider, updating state
- CI/CD version mismatch — runner has different provider version than local
- Lock file outdated —
.terraform.lock.hclpins an older version - Downgraded accidentally — switched to an older Terraform/provider version
Solution 1: Upgrade Provider
# Upgrade to latest matching version
terraform init -upgrade
# Check what version you now have
terraform version
terraform providers
Solution 2: Pin Provider Version
Prevent this from happening again:
terraform {
required_version = ">= 1.7.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.60" # Everyone uses 5.60+
}
}
}
Then update the lock file for all platforms:
terraform providers lock \
-platform=linux_amd64 \
-platform=darwin_arm64
git add .terraform.lock.hcl
git commit -m "chore: update provider lock file"
Solution 3: Terraform Version Mismatch
If the error is about the Terraform binary version (not provider):
Error: state snapshot was created by Terraform v1.9.0,
which is newer than current v1.7.0
# Check your version
terraform version
# Upgrade Terraform
# macOS
brew upgrade terraform
# Linux
curl -LO https://releases.hashicorp.com/terraform/1.9.0/terraform_1.9.0_linux_amd64.zip
unzip terraform_1.9.0_linux_amd64.zip
sudo mv terraform /usr/local/bin/
Solution 4: If You MUST Downgrade
If you need an older version (rare):
# 1. Remove state reference and reimport
terraform state rm aws_instance.web
terraform import aws_instance.web i-0abc123
# 2. Or pull state, edit version (risky, last resort)
terraform state pull > state.json
# Edit the "terraform_version" field
terraform state push state.json
Warning: Downgrading state is risky. Only do this if you understand the schema differences.
Prevention: CI/CD Version Consistency
Pin in CI/CD
# GitLab CI
image:
name: hashicorp/terraform:1.9 # Exact version
entrypoint: [""]
before_script:
- terraform init # Uses lock file versions
Use tfenv for Local Development
# Install tfenv
brew install tfenv
# Set project version
echo "1.9.0" > .terraform-version
# Auto-switches when you cd into the project
tfenv use
Commit the Lock File
Always commit .terraform.lock.hcl — it ensures everyone uses the same provider versions:
git add .terraform.lock.hcl
Hands-On Courses
- Terraform for Beginners on CopyPasteLearn
- Terraform By Example — practical code examples
Conclusion
State created by a newer provider means someone on your team (or CI/CD) used a newer version. Run terraform init -upgrade to match. Prevent future issues by pinning versions in required_providers, committing .terraform.lock.hcl, and using the same Terraform version in CI/CD as locally (tfenv + .terraform-version).