Ron G
Ron G

Reputation: 65

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?

Upvotes: 0

Views: 927

Answers (2)

Ron G
Ron G

Reputation: 65

I had to make this variable a string, not a number.

I had to change my variable definition to string:

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

Upvotes: 1

Jake Nelson
Jake Nelson

Reputation: 2063

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.

Upvotes: 1

Related Questions