Search code examples
terraformterraform-provider-aws

Terraform Upgrade Providers


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?


Solution

  • 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.