Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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"
      configuration_aliases = [ mycloud.alternate ]
    }
  }
}

It does not mention the version.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What does ~> mean in terraform required_providers version? And are there any other writing ways such as >, =?

>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:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading