'Terraform partially interprets a decimal number

I would like to know if some of you encountered the following issue;
While I'm trying to upgrade my EKS cluster to version 1.20 with the following variable-

eks_version = 1.20

This picture shows the result, terraform converts 1.20 to 1.2-
enter image description here

For some reason, terraform not take into account the total decimal number, resulting in an error;

Error: error updating EKS Cluster (stage) version: InvalidParameterException: unsupported Kubernetes version

P.S
I tried to use the format function as well

eks_version = format("%.2s", 1.20)

With the same output. Any ideas on how to make terraform take into account the whole decimal number?



Solution 1:[1]

Ervin's comment is correct.

The answer is to stop formatting it using this method.

The format spec of %.2f says to limit the input 1.20 with a width of 2.

If you want a specific version, remove the call to the format function.

Solution 2:[2]

Thank you guys for your comments!
Your comments helped me realize that I need to make this variable a string, not a number!

I had to change my variable defenition to string:

variable "eks_version" {
  type    = string
  default = "1.20"
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jake Nelson
Solution 2 Ron Gimpelevich