Terraform AWS Provider Version: How to Pin, Check, Upgrade and Downgrade It, the .terraform.lock.hcl File Explained, and "Locked Provider Does Not Match Configured Version Constraint" Fixed

Logeshwaran
—

You set the Terraform AWS provider version in a required_providers block, usually as version = "~> 6.0", which allows any 6.x release but never 7.0. On October 22, 2026, the newest release was hashicorp/aws 6.70.0 (the last 5.x was 5.100.0), and Terraform itself was at 1.17.0. The first terraform init picks the newest version your constraint allows and writes that exact version into .terraform.lock.hcl. From then on, the lock file decides, not your constraint. Here is the part that surprises nearly everyone: plain terraform init never changes a locked version, in either direction. Change ~> 6.0 to ~> 5.0 to go back a major version, and init stops with "locked provider registry.terraform.io/hashicorp/aws 6.70.0 does not match configured version constraint ~> 5.0; must use terraform init -upgrade to allow selection of new versions." The flag is called -upgrade, and the message talks about new versions, but it is also how you downgrade. Run terraform version to see the version you have now. To change it, edit the constraint and run terraform init -upgrade, then commit the updated lock file. This page covers the constraint syntax, the lock file, upgrading from 5.x to 6.x, downgrading safely, and every common provider-version error with its exact message and fix.

Ethan keeps Jake's shop infrastructure in Terraform: an S3 bucket for nightly backups of the repair database, a small EC2 server, and the IAM user the backup script uses. One evening he added a networking module he had found, ran terraform init, and got "no available releases match the given constraints ~> 5.0, >= 6.0.0." Jake read it over his shoulder. "No releases? Did Amazon pull the software?" "There are 513 versions of it," Ethan said. "Our file says 5.x only, and the new module says 6.0 or newer. No version can be both." Fixing it took one line. Understanding why took the evening, and this page is that evening, written down.

⚡ Quick Answer

• Pin it: aws = { source = "hashicorp/aws", version = "~> 6.0" } inside terraform { required_providers { ... } }. Example.

• Check it: terraform version lists the selected provider version, and terraform providers shows who requires what. How.

• Change it (up OR down): edit the constraint, run terraform init -upgrade, commit .terraform.lock.hcl. Upgrade · Downgrade.

• "locked provider ... does not match configured version constraint": the lock file holds an older choice; run terraform init -upgrade. Fix.

• "no available releases match the given constraints": two constraints conflict, or the version does not exist. Fix.

Constraint syntax · The lock file · What changed in v6 · CI and the 833 MB binary · All errors.

New to Terraform? Terraform is a tool that builds cloud infrastructure from text files, so your servers, buckets and permissions live in code you can review and repeat. It does not talk to AWS itself. A provider is a plugin that translates your .tf files into AWS API calls, and the AWS one, hashicorp/aws, is downloaded separately and versioned separately from Terraform. If you have used AWS CloudFormation, a Terraform configuration plays the same role, with the provider standing in for CloudFormation's built-in resource types. If your provider cannot sign in at all, that is a different problem, covered in our "no valid credential sources found" guide.

🧭 NEW HERE? READ THESE FIRST

New to Terraform on AWS? These five pages cover the pieces this guide assumes:

💡 Two different "locks" exist in Terraform. The lock FILE pins provider versions; the state LOCK stops two people applying at once. This page is about the first.

What a Terraform provider is, and Terraform version vs provider version

Every Terraform project involves at least two separate version numbers, and most confusion comes from mixing them up:

  • The Terraform version (also called Terraform Core or the CLI) is the terraform program you run. It reads your files, works out the plan, and manages state. It was 1.17.0 on October 22, 2026. You control which versions may run your code with required_version.
  • The provider version is the version of each plugin, such as hashicorp/aws 6.70.0. The provider knows the AWS resource types, their arguments and their quirks. Its version decides whether aws_s3_bucket accepts a given argument, and whether a bug you hit is fixed yet. You control it with required_providers.

They move independently. The AWS provider ships roughly weekly (6.0.0 came out on June 18, 2025, and 6.70.0 on October 22, 2026), while Terraform releases far less often. A new AWS service or argument appears in a provider release, not a Terraform release. So "update Terraform" rarely fixes a missing argument, but "update the provider" often does.

Where are Terraform providers installed? In the .terraform folder of each working directory. For the AWS provider on Linux, the path is .terraform/providers/registry.terraform.io/hashicorp/aws/6.70.0/linux_amd64/terraform-provider-aws_v6.70.0_x5. That one file is an 833 MB binary (from a 181 MB download), and every working directory gets its own copy unless you turn on the plugin cache (see CI and caching). Never commit the .terraform folder. Do commit .terraform.lock.hcl.

How to specify the AWS provider version

Declare the provider inside the top-level terraform block, in a required_providers block, with a source and a version constraint. You can pin the Terraform version in the same block:

terraform {
  required_version = ">= 1.5.0"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 6.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

Each part has a job:

  • aws is the local name, the name this module uses for the provider. Use the provider's preferred name (aws for hashicorp/aws), because every resource type starts with it: aws_instance, aws_s3_bucket.
  • source = "hashicorp/aws" is the registry address, short for registry.terraform.io/hashicorp/aws. For HashiCorp's own providers, Terraform can guess it. For every other publisher you must write it, or you get the error in "does not have a provider named".
  • version = "~> 6.0" is the constraint: the set of versions you accept. Terraform picks the newest version in that set the first time, then records the pick in the lock file.
  • required_version is the constraint on Terraform itself. A teammate running an older Terraform gets a clear error instead of a confusing one.

Put this block in a file called versions.tf or terraform.tf by convention. The name does not matter to Terraform, which reads every .tf file in the folder, but a predictable name makes the version easy to find for the next person, who may be you in six months. Each module can have only one required_providers block. A second block in another file, even for a different provider, stops init with "Duplicate required providers configuration", so list every provider in the same block. Every module (folder) declares its own requirements, and Terraform combines all of them.

Version constraint syntax, with examples

A constraint is one or more conditions separated by commas, and a version must satisfy all of them. These are the operators:

ConstraintAllowsTypical use
"~> 6.0"6.0 up to, not including, 7.0Root modules: new features and fixes, no breaking major
"~> 6.70.0"6.70.0 up to, not including, 6.71.0Patch releases only; very cautious
"~> 6.70"6.70 and any later 6.xA floor inside 6.x, with the 7.0 ceiling
">= 6.0"6.0 and everything newer, including 7.xReusable modules: minimum only
">= 6.20, < 7.0"6.20 through the last 6.xSame as ~> 6.20, written out
"6.70.0" or "= 6.70.0"Exactly 6.70.0Rarely needed; the lock file already pins exactly
"!= 6.65.0"Anything except 6.65.0Skipping one release with a known bug

The ~> operator ("pessimistic constraint") is the one to understand. It lets only the right-most number you wrote increase. ~> 6.0 has two numbers, so the second may grow (6.1, 6.70) but the first may not. ~> 6.70.0 has three, so only the third may grow (6.70.1, 6.70.5). That is why ~> 6.70 and ~> 6.70.0 behave very differently even though they look alike.

Three syntax details trip people up. First, wildcards are not allowed. version = "6.*" fails with "Invalid version constraint ... This string is not a valid version constraint." Use ~> 6.0. Second, pre-release versions such as 7.0.0-beta1 are only selected when you name them exactly. The >, >=, <, <= and ~> operators never match a pre-release. Third, the constraint is a string, so it needs quotes, and a stray space inside an operator ("> = 6.0") is also invalid.

Provider version pinning: what to pin, and where

HashiCorp's own guidance for version constraints comes down to two rules, and they solve Ethan's conflict before it happens:

  • Root modules (the folder you run terraform apply in) should use ~> to set both a lower and an upper bound for each provider. ~> 6.0 says "any 6.x, never 7.0 by surprise."
  • Reusable modules (code that other configurations call) should set only a minimum, such as >= 6.0. That way the module works with whatever newer provider the caller chooses, and two modules cannot paint you into a corner with incompatible ceilings.

On top of that, commit the lock file. The constraint says which versions you accept. The lock file says which one you actually use, down to the checksum. With the lock file committed, your laptop, a teammate's laptop and the CI pipeline all install the identical provider until someone deliberately upgrades it in a reviewed change. Without it, each machine picks "the newest allowed today", and a weekly provider release can change behavior between Monday's plan and Thursday's apply.

A pinning setup that works for a small team looks like this. The root module uses ~> 6.0, modules use >= 6.0, the lock file is committed, and someone runs terraform init -upgrade on a schedule (every week or two) in a branch, reads the plan, and merges the lock file change. "So we only get new versions when you say so?" Jake asked. "When I say so, and after I have seen the plan," Ethan said.

The .terraform.lock.hcl file explained

The dependency lock file is created by the first terraform init in a working directory, next to your root .tf files. For the AWS provider it looks like this:

# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.

provider "registry.terraform.io/hashicorp/aws" {
  version     = "6.70.0"
  constraints = "~> 6.0"
  hashes = [
    "h1:HCr4MYgxlkFBOAeWKOoktNNzZaQX8ZZY4YTxmL/1V/Y=",
    "zh:068ca7ed4fc77e3d63d7fac54515a426a32f3dc143b55a6ad00963fe68289955",
    "zh:2d8c016b3809ab32f536b01bf2c98fcbdeb066b7b7e50f756ff6ff1e0b0539c7",
    # ...14 more zh: lines, one per published platform package
  ]
}
  • version is the exact selection, the one every later terraform init re-installs.
  • constraints records the constraint that was in force when it was chosen, for reviewers.
  • hashes are checksums. zh: lines are SHA-256 hashes of the official zip packages, one per platform (Linux, macOS, Windows, and so on), copied from HashiCorp's signed checksum list. The h1: line is a hash of the unpacked package for the platform that ran init. On first install from the public registry, the AWS provider entry gets 16 zh: lines and 1 h1: line.

From the second run on, Terraform installs exactly the recorded version and checks that the package matches one of the hashes. HashiCorp calls this "trust on first use": you vet a provider version once, and Terraform refuses anything that differs later. Some things the lock file does not do:

  • It does not lock module versions. Terraform does not remember module selections and always takes the newest module version that matches the module's version argument. Pin modules with an exact version if you need repeatability.
  • It is not the state lock. The "Error acquiring the state lock" message is about two runs touching the same state at once, and it has its own fix (our state lock guide covers it). The lock file and the state file are unrelated: one pins software, the other records your real resources.
  • It is not per module. There is one lock file for the whole configuration, in the root folder.

Should the Terraform lock file be in git? Yes. Commit .terraform.lock.hcl, and put .terraform/ (the downloaded binaries) in .gitignore. Review lock file diffs like code: a changed version line is a provider upgrade, and new hashes lines for the same version usually mean someone added checksums for another platform.

How to check which Terraform provider version you are using

You have four ways to check, depending on what you need:

  • terraform version prints Terraform's version and every provider selected in this working directory:
    Terraform v1.17.0
    on linux_amd64
    + provider registry.terraform.io/hashicorp/aws v6.70.0
    If no provider line appears, the directory has not been initialized yet.
  • terraform version -json gives the same information for scripts, under provider_selections, plus a terraform_outdated flag.
  • terraform providers shows the requirements, module by module, which is how you find the module that is causing a conflict:
    Providers required by configuration:
    .
    ├── provider[registry.terraform.io/hashicorp/aws] ~> 5.0
    └── module.net
        └── provider[registry.terraform.io/hashicorp/aws] >= 6.0.0
  • The lock file shows the selection without running anything: look for the version line under provider "registry.terraform.io/hashicorp/aws".

To see which versions exist, open the provider's page on the Terraform Registry, which has every release, and its changelog in the provider's GitHub repository. There were 513 versions on October 22, 2026. Before a big jump, read the changelog entries between your version and the target. They list new arguments, fixed bugs and, rarely within a major version, behavior changes.

How to upgrade the Terraform AWS provider

Upgrading inside a major version (6.40 to 6.70, say) is routine. Upgrading across a major version (5.x to 6.x) needs a little care. Either way, the steps are the same:

  1. Start clean. Run terraform plan on the current version and make sure it shows no changes and no deprecation warnings. Then you know any later difference comes from the upgrade.
  2. For a major upgrade, go to the latest of your current major first. HashiCorp's v6 guide asks you to upgrade to the latest 5.x (5.100.0) and get a clean plan with no deprecation warnings before moving to 6.0. The 5.x deprecation warnings point at exactly the code that 6.0 breaks.
  3. Change the constraint if it does not already allow the target, for example from ~> 5.92 to ~> 6.0, in the root module and in any of your own modules that set an upper bound.
  4. Run terraform init -upgrade. Terraform ignores the old selection, picks the newest version that matches the constraint, downloads it, and rewrites the lock file. You will see "Terraform has made some changes to the provider dependency selections recorded in the .terraform.lock.hcl file. Review those changes and commit them..."
  5. Run terraform plan and read every change. A provider upgrade should usually produce an empty plan. Anything else is either a fix you wanted, a new default, or a breaking change you need to adjust for (see what changed in v6).
  6. Commit the lock file together with any code changes, in one reviewed change.

What does terraform init -upgrade do? It tells init to disregard the versions recorded in the lock file and select again: the newest provider version matching your constraints, and the newest module versions matching module constraints. That second part is easy to forget. If your modules use loose constraints, -upgrade can pull newer module code too, so read the plan. -upgrade does not upgrade Terraform itself, and it never goes beyond your constraint. With ~> 6.0 it will never jump to 7.0.

Upgrade one provider only. terraform init -upgrade re-selects every provider. If you want to move aws but not, say, random, tighten the others' constraints temporarily to their current versions (random = { version = "3.9.1" }), run -upgrade, then restore them. The lock file diff should show only the aws block changing.

How to downgrade the Terraform AWS provider (and the state trap)

Sometimes a new provider release has a bug that breaks your plan, and you need to go back. The steps mirror an upgrade, with one important difference afterward:

  1. Change the constraint to exclude the bad release: an exact older version ("6.68.0"), an upper bound (">= 6.0, < 6.69.0"), or a skip ("~> 6.0, != 6.69.0").
  2. Run terraform init -upgrade, not plain init. Plain init refuses with the "locked provider ... does not match configured version constraint" message, even though you are going backward, because the lock file still holds the newer version.
  3. Run terraform plan and confirm it no longer shows the bug.
  4. Commit the lock file, and add a comment next to the constraint saying why, so nobody removes it blindly.

The trap is state. Providers can store a resource in state with a newer schema version than an older provider understands. If you apply with the newer provider and then downgrade, the next plan can stop with:

Error: Resource instance managed by newer provider version

The current state of aws_example.this was created by a newer provider version than
is currently selected. Upgrade the aws provider to work with this state.

Terraform will not let an older provider read state it may misunderstand, so the fix is to go forward again or restore older state. Either upgrade to the version that wrote the state (or newer), or restore the state file from before the apply. Keeping state in an S3 bucket with versioning enabled turns that restore into a two-minute job instead of a disaster. So downgrade before applying with a bad release whenever you can. Downgrading after a plan is free; downgrading after an apply may not be.

Downgrading Terraform itself works differently: install the older terraform binary. The required_version setting is how a team keeps everyone on a known range of Terraform versions, so one person's much newer or older CLI does not touch shared state.

Upgrade modules without touching providers, and remove a provider cleanly

Modules only. If you want newer module code but the same provider versions, skip -upgrade and run terraform get -update. It checks every downloaded module for a newer version that matches its version argument and installs it, without re-selecting providers. Then run terraform plan as usual. If a new module version needs a newer provider than your lock file holds, init or plan tells you with the "locked provider" message, and that is your cue to do a deliberate provider upgrade as well. Modules from a Git source follow the ref in the URL, so pin a tag (?ref=v2.4.0) rather than a branch if you want them to stay put.

Removing a provider. Delete its entry from required_providers and any provider blocks, but only after every resource it manages is destroyed or moved out of state. Otherwise the next plan stops with "Provider configuration not present". Then run plain terraform init. Terraform drops the unused provider from the lock file and prints "Terraform has made some changes to the provider dependency selections recorded in the .terraform.lock.hcl file." Commit that change too, so the next person does not download a provider nobody uses. No -upgrade is needed here, because nothing new is being selected.

The same rules apply to every other provider. azurerm, google, kubernetes and random all use the same constraint syntax, the same lock file and the same -upgrade behavior, each with its own major versions and upgrade guides. Learn the pattern once on the AWS provider, and it carries over to every provider you add later.

Terraform provider version errors, with exact messages and fixes

Every message below is what Terraform 1.17.0 prints, word for word, with your own provider, version and resource names in place of the ones shown. Most of them start with "Error: Failed to query available provider packages", so the line after that is the one that tells you what is wrong.

Message (key part)CauseFix
locked provider ... does not match configured version constraintConstraint changed; lock file holds the old pickterraform init -upgrade
no available releases match the given constraintsConflicting constraints, or a version that does not existterraform providers, then fix the constraint
does not have a provider named registry.terraform.io/hashicorp/...Non-HashiCorp provider with no sourceAdd source in every module that uses it
Inconsistent dependency lock fileplan/apply before init, or lock file out of dateterraform init
doesn't match any of the checksums previously recordedPackage differs from the lock file's hashesterraform providers lock with your platforms
is not available for darwin_arm64 (or your platform)That provider version has no build for your OS/CPUNewer provider version, or a replacement provider
Unsupported Terraform Core versionrequired_version excludes your CLIInstall a matching Terraform
Invalid version constraintBad syntax such as "6.*"Use "~> 6.0"
Resource instance managed by newer provider versionDowngraded after a newer provider wrote stateUpgrade again, or restore older state
Provider configuration not presentA provider block (often an alias) was deleted while its resources existRe-add the block, destroy or move the resources, then remove it

"locked provider ... does not match configured version constraint"

The full message reads: "Could not retrieve the list of available versions for provider hashicorp/aws: locked provider registry.terraform.io/hashicorp/aws 5.100.0 does not match configured version constraint ~> 6.0; must use terraform init -upgrade to allow selection of new versions." Your constraint changed, but the lock file still holds a version outside it. Terraform will not silently swap provider versions, because that could change what your next apply does. Run terraform init -upgrade, read the plan, and commit the new lock file. This is the most common provider-version error by far, and it appears in CI right after someone edits the constraint without committing the updated lock file. The fix there is to run -upgrade locally and commit the result, not to add -upgrade to the pipeline.

"no available releases match the given constraints"

Terraform combined every constraint for the provider from every module, and no published version satisfies all of them at once. Ethan's message said so directly: "no available releases match the given constraints ~> 5.0, >= 6.0.0". The root wanted 5.x and the module wanted 6.0 or newer. Run terraform providers to see which module wants what, then do one of three things: raise the root constraint (the usual answer, after an upgrade check), use an older module version that supports your provider, or ask the module's author to loosen an over-tight ceiling. The same message with a single constraint, such as "no available releases match the given constraints ~> 9.0", simply means that version does not exist yet. Check for typos like ~> 60.

"provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/datadog"

You used a resource from a provider that is not published by HashiCorp (here datadog_monitor) without declaring its source. Terraform guessed hashicorp/datadog, which does not exist, and helpfully adds "Did you intend to use datadog/datadog? If so, you must specify that source address in each module which requires that provider." Add datadog = { source = "datadog/datadog", version = "..." } to required_providers in every module that uses it, not just the root. A child module without the declaration makes Terraform guess again.

"Inconsistent dependency lock file"

"The following dependency selections recorded in the lock file are inconsistent with the current configuration: provider registry.terraform.io/hashicorp/aws: required by this configuration but no version is selected. To make the initial dependency selections that will initialize the dependency lock file, run: terraform init." You ran plan or apply in a folder that was never initialized, or you added a provider since the last init. Run terraform init. In CI, make sure the init step runs in the same directory as the plan step.

"doesn't match any of the checksums previously recorded in the dependency lock file"

"Error while installing hashicorp/aws v6.70.0: the current package for registry.terraform.io/hashicorp/aws 6.70.0 doesn't match any of the checksums previously recorded in the dependency lock file." The package Terraform downloaded is not one the lock file has seen. Most often a teammate created the lock file through a filesystem or network mirror, which records hashes only for their own platform, and you are on another (a Mac creating the lock, a Linux CI runner installing). Fix it once by recording every platform your team uses, then commit the result:

terraform providers lock \
  -platform=linux_amd64 \
  -platform=darwin_arm64 \
  -platform=windows_amd64

It reports each platform as it goes, for example "Obtained hashicorp/aws checksums for darwin_arm64; Additional checksums for this platform are now tracked in the lock file." If the hashes really do not match the official registry's for that version, stop and find out why before forcing anything. That is exactly the tampering this check exists to catch.

"... is not available for darwin_arm64"

Old provider versions were built before Apple Silicon (and some never had builds for every platform). For example, hashicorp/template 2.2.0, the last release of that provider (October 2020), fails with "provider registry.terraform.io/hashicorp/template 2.2.0 is not available for darwin_arm64." For the AWS provider, any recent version has builds for all common platforms, so the fix is to upgrade past the old pin. For providers that no longer get releases, like template, replace them, for example with Terraform's built-in templatefile() function.

"Unsupported Terraform Core version"

"This configuration does not support Terraform version 1.17.0. To proceed, either choose another supported Terraform version or update this version constraint." The required_version setting excludes the terraform you are running. Install a version inside the range rather than loosening the constraint. Somebody set it for a reason, often a state format or language feature.

"Provider configuration not present"

"To work with aws_instance.old (orphan) its original provider configuration at provider["registry.terraform.io/hashicorp/aws"].backup is required, but it has been removed." You deleted a provider block, usually an aliased one like alias = "backup" for a second region, while resources created through it still exist in state. Put the block back, then either destroy those resources or move them to another provider configuration, and only then remove the block. This is not a version problem, but it shows up in the same searches, and it gets more common in v6 as people replace extra provider aliases with the new per-resource region argument.

What changed in AWS provider v6 (upgrading from 5.x)

Version 6.0.0 (June 18, 2025) was the last major release, so most "upgrade the AWS provider" work today is 5.x to 6.x. These are the changes most configurations hit, from HashiCorp's v6 upgrade guide:

AreaWhat changed in 6.0What to do
RegionsMost resources gained a region argumentOptional: replace extra provider aliases used only for another Region
aws_s3_bucketregion now means the new per-resource Region; the bucket's Region attribute is bucket_regionChange references from .region to .bucket_region
data "aws_region"name deprecatedUse .region
data "aws_ami"most_recent = true without owners or an owner/image filter is now an error, not a warningAdd owners = ["amazon"] (or your account ID)
aws_instanceuser_data stored in clear text, no longer hashed; cpu_core_count and cpu_threads_per_core removedKeep secrets out of user_data; use a cpu_options block
aws_launch_templateelastic_gpu_specifications and elastic_inference_accelerator removedDelete them (both services reached end of life in 2024)
Provider blockendpoints.opsworks, endpoints.simpledb/sdb, endpoints.worklink removedDelete them
S3 in us-east-1s3_us_east_1_regional_endpoint = "legacy" deprecated, removal planned for 7.0Remove the setting or set it to regional
Removed servicesOpsWorks Stacks, SimpleDB and WorkLink resources removedRemove them from code and state first, on 5.x

The aws_instance user_data change deserves a second look. In 5.x, the plan showed a hash of your user data. From 6.0 it shows and stores the full text, so anything secret in it (a password in a bootstrap script, say) is now readable in plan output and in state. Move secrets to AWS Secrets Manager or SSM Parameter Store and fetch them at boot. If you hit Unsupported argument errors after the upgrade, search the upgrade guide for the argument name. Nearly every removed argument is listed with its replacement.

Ethan's upgrade took twenty minutes. He moved to 5.100.0 first and fixed two deprecation warnings (a data "aws_region" .name and an aws_ami lookup without owners). Then he changed the constraint to ~> 6.0, ran terraform init -upgrade, and got an empty plan. "Twenty minutes for a version number," Jake said. "Twenty minutes now, or a Saturday later," Ethan said.

CI/CD, the plugin cache, and the 833 MB binary

The AWS provider is big. Version 6.70.0 is a 181 MB download that unpacks to an 833 MB file, and by default every working directory downloads and stores its own copy. A repository with eight Terraform folders keeps over 6 GB of identical binaries, and a CI job that starts from scratch downloads 181 MB on every run. Three settings fix that:

  • The plugin cache. Set plugin_cache_dir = "$HOME/.terraform.d/plugin-cache" in your CLI configuration file (~/.terraformrc, or on Windows a file named terraform.rc in your %APPDATA% folder, with forward slashes in the path), or export TF_PLUGIN_CACHE_DIR for one shell. Create the directory first, because Terraform will not create it. Each version is then downloaded once and linked into each working directory. Terraform never deletes old versions from the cache, so clean it now and then, and do not share one cache between parallel terraform init runs, because the cache is not guaranteed to be concurrency-safe.
  • Cache that folder between CI runs, keyed on the lock file's contents, so a pipeline only downloads when the lock file changes.
  • terraform init -lockfile=readonly in CI. It verifies checksums against the committed lock file but refuses to change it, so a pipeline can never quietly pick a different provider than the one that was reviewed. It conflicts with -upgrade, which is the point: upgrades happen in reviewed branches, not in pipelines.

For machines without internet access, terraform providers mirror /path/to/dir downloads the providers your configuration needs into a folder that can serve as a filesystem mirror. Copy it across, then point a provider_installation { filesystem_mirror { ... } } block in the CLI configuration at it. That is the supported way to "download a Terraform provider manually". Run terraform providers lock with every platform beforehand, because installs from a mirror can only record checksums for the platform that ran them.

If your pipeline also authenticates to AWS with GitHub Actions, our GitHub Actions OIDC guide covers the role setup, and the S3 backend guide covers state permissions and init -reconfigure versus -migrate-state, which are backend options rather than provider options.

Upgrading Terraform itself, and required_version

The provider and the CLI upgrade separately. To update the terraform binary, download the new version for your platform from HashiCorp's releases site (releases.hashicorp.com, with a SHA256SUMS file to verify it), or use your package manager if you installed it that way. Then check with terraform version. On Windows, replace the old terraform.exe in the folder on your PATH and open a new terminal. A common "terraform not updating on Windows" cause is an older copy earlier in PATH. Run where terraform to list every copy Windows can find.

Protect shared projects with required_version. A setting like required_version = ">= 1.5.0, < 2.0.0" keeps everyone inside a known range. Following the same rule as providers, reusable modules should state only a minimum. terraform version -json also reports a terraform_outdated flag when a newer Terraform release exists, which is a nudge, not an instruction. Plan Terraform upgrades the same way as provider upgrades: one change, a clean plan before and after, and the whole team moving together.

Troubleshooting by symptom

I changed the version but terraform init still installs the old one

The lock file wins until you run terraform init -upgrade. Plain init re-installs the locked version, or errors if it no longer fits your constraint.

CI fails with "locked provider" but my laptop works

You ran -upgrade locally but did not commit .terraform.lock.hcl. Commit it, so CI installs the same version.

A new module breaks terraform init

Its provider constraint conflicts with yours. Run terraform providers to see both, then align them, usually by upgrading your root constraint.

The lock file changes every time a teammate runs init

They are on another platform and adding its checksums. Run terraform providers lock with all your platforms once and commit it.

terraform init takes minutes and fills the disk

Each folder downloads its own 833 MB AWS provider. Turn on the plugin cache and cache it in CI.

After a downgrade, plan says "managed by newer provider version"

The newer provider already wrote state. Upgrade back to it, or restore state from before that apply.

terraform init -upgrade did not move to 7.0

A ~> 6.0 constraint never allows 7.0. Change the constraint deliberately when a new major version ships, after reading its upgrade guide.

An unfamiliar provider error appears right after an upgrade

Read the provider changelog between your old and new versions, and pin back with != or an upper bound while you fix it.

Terraform AWS provider version: frequently asked questions

What is the latest Terraform AWS provider version?

On October 22, 2026, the latest hashicorp/aws release was 6.70.0. The last 5.x release was 5.100.0, and 6.0.0 came out on June 18, 2025.

How do I specify the Terraform AWS provider version?

Add aws = { source = "hashicorp/aws", version = "~> 6.0" } inside terraform { required_providers { } } in your root module, then run terraform init.

How do I check my Terraform provider version?

Run terraform version in the working directory. It lists each selected provider, such as provider registry.terraform.io/hashicorp/aws v6.70.0.

How do I upgrade the Terraform AWS provider?

Allow the new version in your constraint, run terraform init -upgrade, review terraform plan, and commit the updated .terraform.lock.hcl file.

How do I downgrade a Terraform provider version?

Set a constraint that excludes the newer version and run terraform init -upgrade. Plain init refuses because the lock file still holds the newer version.

What does terraform init -upgrade do?

It ignores the versions recorded in the lock file and selects the newest providers and modules that match your constraints, then updates the lock file.

What does ~> mean in Terraform?

It lets only the right-most number you wrote increase. ~> 6.0 allows any 6.x but not 7.0, and ~> 6.70.0 allows only 6.70.x.

What is the .terraform.lock.hcl file?

It is the dependency lock file. It records the exact provider versions and checksums that terraform init selected, so every run installs the same providers.

Should I commit the Terraform lock file to git?

Yes. Commit .terraform.lock.hcl so every machine and pipeline uses the same provider versions, and ignore the .terraform folder.

What is the difference between the Terraform lock file and the state lock?

The lock file pins provider versions. The state lock stops two runs from changing the same state at once. They are unrelated.

What is the difference between Terraform version and provider version?

The Terraform version is the CLI you run, set with required_version. The provider version is each plugin, such as hashicorp/aws, set in required_providers.

Why does Terraform say no available releases match the given constraints?

No published version satisfies every constraint at once, usually because a module and the root disagree, or because the version does not exist yet.

How do I fix locked provider does not match configured version constraint?

Run terraform init -upgrade so Terraform can select a version that matches your new constraint, then commit the updated lock file.

Where are Terraform providers installed?

In the .terraform/providers folder of each working directory, or in the shared plugin cache if you set plugin_cache_dir or TF_PLUGIN_CACHE_DIR.

Can I use wildcards like 6.* in a Terraform version constraint?

No. "6.*" fails with Invalid version constraint. Use ~> 6.0 for the same meaning.

Does the Terraform lock file pin module versions?

No. It only tracks providers. Pin modules with an exact version argument if you need them to stay the same.

For readers preparing for an AWS certification

We have been covering AWS certifications alongside our fixes, so here is a short extra for readers studying for one. If you only came for the fix, you already have it; feel free to skip this part.

Exams that test this topic: DevOps Engineer – Professional (DOP-C02) • CloudOps Engineer – Associate (SOA-C03) • Developer – Associate (DVA-C03 from December 1, 2026).

Here are the exam-style questions this topic tends to raise, with the reasoning you need to answer them:

1. A deployment pipeline must build test and production from identical infrastructure code, with no dependency changing between the two runs. What is the practice?

Pin and commit dependency versions (for Terraform, the .terraform.lock.hcl file) and promote the same reviewed artifact through every stage.

2. A bad terraform apply overwrote the state file stored in an S3 bucket. Which S3 feature lets the team recover the previous state?

S3 Versioning on the state bucket, which keeps the earlier object version so it can be restored.

3. A CodeBuild project running Terraform downloads the same large provider binaries on every build. How do you shorten build time?

Enable CodeBuild caching (S3 or local cache) for the Terraform plugin cache directory.

4. An EC2 bootstrap script in user data contains a database password, and user data is visible in plain text. Where should the secret live instead?

In AWS Secrets Manager or an SSM Parameter Store SecureString, fetched at boot using the instance profile role.

5. A CI job must never pick a provider version that was not reviewed, but it must still verify checksums. Which Terraform init option fits?

terraform init -lockfile=readonly with the lock file committed to the repository.

6. Two engineers ran terraform apply against the same state at the same time and corrupted it. Which control prevents this?

State locking in the backend, so only one run can write the state at a time.

Exam codes and dates change often. Our AWS certification changes page keeps track of what is current.

πŸ“š ALSO READ

More Terraform and infrastructure-as-code fixes:

📌 Run terraform version now and note the provider version. It is the first thing anyone helping you will ask.

The shop's Terraform folder now has a versions.tf with ~> 6.0, a committed lock file, and a calendar reminder every other Friday that says "init -upgrade, read the plan". Jake asked what happens if Ethan is on holiday when a bad release lands. "Nothing," Ethan said. "Nothing changes until someone runs that command and reads the plan. That is the whole idea."

📌 If you keep one line from this page

Pin with ~> 6.0 in the root and >= in modules, commit .terraform.lock.hcl, and change versions only with terraform init -upgrade followed by a plan you actually read, whether you are going up or down.

hashicorp/aws 6.70.0 · last 5.x: 5.100.0 · Terraform 1.17.0 · October 22, 2026.

Revision note. Written October 22, 2026, against Terraform 1.17.0 and hashicorp/aws 6.70.0, with error messages exactly as Terraform prints them. "A stitch in time saves nine," the proverb says, and a lock file is that stitch.

Related