In an existing Terraform directory:
~ terraform version
Terraform v0.11.11
+ provider.aws v1.51.0
If I setup a new Terraform directory:
~ terraform version
Terraform v0.11.11
+ provider.aws v1.55.0
How do I upgrade my provider.aws
? If I set version = "~> 1.55.0"
in the provider "aws"
in my .tf
file, I get an error:
* provider.aws: no suitable version installed
version requirements: "~> 1.55.0"
versions installed: "1.51.0"
I expected to find a terraform update
command or something similar. But I can't find that.
Am I not supposed to upgrade the provider? Do I need to delete state, rerun init
and then refresh
? Or is there a better way?
Use terraform init -upgrade command to upgrade the latest acceptable version of each provider. Show activity on this post. Just run terraform init to upgrade AWS plugin version, no need to delete state file. it will only upgrade if you specify the -upgrade option specified by the other answer.
Update workspace Terraform versionOn the Terraform Cloud workspace settings page, update your workspace's version to 0.13. 7 and save the change. Then, merge your pull request to update the version constraint on your main branch.
The terraform block contains the required_providers block, which specifies the provider local name, the source address, and the version. When you initialize this configuration, Terraform will download: Version 3.0. 0 of the random provider. The latest version of the AWS provider that is at greater than 2.0.
There is two solutions to solve this problem:
rm -fr .terraform
and do a terraform init
again. This could be dangerous if the Terraform state is in that folder.-upgrade
argument to the init command in order to upgrade provider versions within constraint limits.Use terraform init -upgrade command to upgrade the latest acceptable version of each provider.
Before Upgrade
ubuntu@staging-docker:~/terraform$ terraform -version
Terraform v0.12.8
+ provider.aws v2.16.0
+ provider.template v2.1.2
Command to upgrade
ubuntu@staging-docker:~/terraform$ terraform init -upgrade
Upgrading modules...
- asg in asg
- ecs in ecs
- lambda in lambda
- lt in lt
Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.27.0...
- Downloading plugin for provider "template" (hashicorp/template) 2.1.2...
The following providers do not have any version constraints in configuration,
so the latest version was installed.
To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.
* provider.aws: version = "~> 2.27"
* provider.template: version = "~> 2.1"
After Upgrade
ubuntu@staging-docker:~/terraform$ terraform version
Terraform v0.12.8
+ provider.aws v2.27.0
+ provider.template v2.1.2
Just run terraform init
to upgrade AWS plugin version, no need to delete state file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With