Search code examples
terraform

What does "~>" mean in terraform required_providers version?


I am tring to understand how version in Terraform work.

For example this demo in the Terraform doc:

terraform {
  required_providers {
    mycloud = {
      source  = "mycorp/mycloud"
      version = "~> 1.0"
    }
  }
}

I didn't find anything related in the official Terraform document related with version especially this ~>. Did I miss?

What does ~> mean in terraform required_providers version? Is there any document? Thanks


Solution

  • This is known as "Dependency Pinning" or "Version Constraints" and defines, how strict you want to use the defined version of a dependency and how to handle available updates.

    Here is a quote, from the official Terraform documentation:

    ~>: Allows only the rightmost version component to increment. For example, to allow new patch releases within a specific minor release, use the full version number: ~> 1.0.4 will allow installation of 1.0.5 and 1.0.10 but not 1.1.0. This is usually called the pessimistic constraint operator.

    If you want to learn more about "major", "minor" etc. versions, please have a look on the Semantic Versioning Specification.

    Other available operators are !=, =, >, >=, < and <=.

    More information: