Terraform Upgrade Providers

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.

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

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.