Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform 0.13 does not support optional keyword #99

Closed
KevinSnyderCodes opened this issue Nov 29, 2023 · 2 comments
Closed

Terraform 0.13 does not support optional keyword #99

KevinSnyderCodes opened this issue Nov 29, 2023 · 2 comments

Comments

@KevinSnyderCodes
Copy link

KevinSnyderCodes commented Nov 29, 2023

https://github.com/rancherfederal/rke2-aws-tf/blob/v2.4.2/modules/agent-nodepool/variables.tf#L77C1-L94C2

variable "asg" {
  description = "Node pool AutoScalingGroup scaling definition"
  type = object({
    min                  = number
    max                  = number
    desired              = number
    suspended_processes  = optional(list(string))
    termination_policies = optional(list(string))
  })

  default = {
    min                  = 1
    max                  = 10
    desired              = 1
    suspended_processes  = []
    termination_policies = ["Default"]
  }
}

https://github.com/rancherfederal/rke2-aws-tf/blob/v2.4.2/modules/agent-nodepool/versions.tf

terraform {
  required_version = ">= 0.13"
}
~ terraform --version

Terraform v0.13.0

~ cd modules/agent_nodepool && terraform init

There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Invalid type specification

  on variables.tf line 83, in variable "asg":
  83:     suspended_processes  = optional(list(string))

Keyword "optional" is not a valid type constructor.


Error: Invalid type specification

  on variables.tf line 84, in variable "asg":
  84:     termination_policies = optional(list(string))

Keyword "optional" is not a valid type constructor.

According to the Terraform changelog, the optional keyword was added as an experiment in Terraform 0.14 and made official in Terraform 1.3.

Solution: Remove the optional keyword, OR bump the required Terraform version to >= 1.3.

This affects v2.4.2, the latest version of this module.

@adamacosta
Copy link
Collaborator

We'll have to bump the required Terraform version. I think the only other way to add the suspended processes and termination policies without breaking any current deployments not setting those is to make the type constraint any, but if you use any, you can't set a default value without creating an implicit type constraint.

@adamacosta
Copy link
Collaborator

Fixed by #102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants