Terraform Upgrade Providers

terraform providers
terraform custom provider
terraform variables
terraform download
terraform init
terraform plan
terraform modules
terraform backend

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?

There is two solutions to solve this problem:

  1. Just remove the terraform cache rm -fr .terraform and do a terraform init again. This could be dangerous if the Terraform state is in that folder.
  2. There is indeed an -upgrade argument to the init command in order to upgrade provider versions within constraint limits.

Terraform AWS Provider Version 3 Upgrade Guide, Upgrading any provider versions that are not compatible with Terraform v0.12. installed the required providers to support the configuration upgrade process. » Upgrading the Consul Terraform Provider This page includes details on our compatibility promise and guidelines to follow when upgrading between versions of the provider. Whenever possible, we recommend verifying upgrades in isolated test environments. » Upgrading to 2.4.0 » Changes to consul_service

Just run terraform init to upgrade AWS plugin version, no need to delete state file.

Terraform AWS Provider Version 2 Upgrade Guide, This page includes details on our compatibility promise and guidelines to follow when upgrading between versions of the provider. Whenever possible, we  When terraform init is re-run with providers already installed, it will use an already-installed provider that meets the constraints in preference to downloading a new version. To upgrade to the latest acceptable version of each provider, run terraform init -upgrade. This command also upgrades to the latest versions of all Terraform modules.

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

Upgrading to Terraform 0.12, (0.12. 26). Please download the proper package for your operating system and architecture. Since Terraform v0.10, Terraform providers are distributed separately from the Terraform binary. This lets them update at different paces, and allows a wider group of people to collaborate on the providers. This is mostly good, but it does introduce a new step for upgrading providers. It is slightly counterintuitive, but to upgrade your providers, run

Command: init, Terraform OCI Provider Version 3. » New Installation. To use the latest OCI Terraform Provider, version 3, run terraform init on the directory that contains the​  There is indeed an -upgrade argument to the init command in order to upgrade provider versions within constraint limits. Just run terraform init to upgrade AWS plugin version, no need to delete state file. Use terraform init -upgrade command to upgrade the latest acceptable version of each provider.

Upgrading the Consul Terraform Provider, Since Terraform v0.10, Terraform providers are distributed separately from the Terraform binary. This lets them update at different paces, and  Many of the topics discussed, except for the actual provider upgrade, can be performed using the most recent 2.X version of the provider. Version 3.0.0 of the AWS provider for Terraform is a major release and includes some changes that you will need to consider when upgrading. This guide is intended to help with that process and focuses only on changes from version 1.X to version 3.0.0.

Download Terraform, Learn about Terraform 0.12 and how you can update your providers to harness its language improvements. » Upgrade Guides Terraform's major releases can include an upgrade guide to help upgrading users walk through backwards compatibility issues and changes to expect. See the navigation for the available upgrade guides.

Comments
  • it will only upgrade if you specify the -upgrade option specified by the other answer.