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

fix: incorrect node_pools variable type #1424

Merged
merged 2 commits into from
Oct 26, 2022

Conversation

michaellzc
Copy link
Contributor

@michaellzc michaellzc commented Oct 12, 2022

node_pool map is a mix of string, bool, and number. therefore, it is better to use map(any) to indicate its type

moreover, list(map(string)) is breaking the use of this module in cdktf.

cdktf infers the type of module options based on the provided variable type. in the generated code, it will produce []map[string]string for node_pools option,
but we want []map[string]interface{} in order to pass correct value

e.g. initial_node_count is a number not string

│ Error: Incorrect attribute value type
│
│   on .terraform/modules/gke_self_15C14BFE/modules/beta-private-cluster/cluster.tf line 434, in resource "google_container_node_pool" "pools":
│  434:   initial_node_count = lookup(each.value, "autoscaling", true) ? lookup(
│  435:     each.value,
│  436:     "initial_node_count",
│  437:     lookup(each.value, "min_count", 1)
│  438:   ) : null
│     ├────────────────
│     │ each.value is map of string with 16 elements
│
│ Inappropriate value for attribute "initial_node_count": a number is required.

notes: this change is fairly safe and I did not run any integration test from this repo

`node_pool` variables are a mix of string, bool, number
therefore, it is better to use `map(any)` to indicate its type

moreover, the use of `list(map(string))` is breaking
the use of this module in `cdktf`.

in the generated code it will produce
`[]map[string]string` for `node_pools` option
but we want `[]map[string]interface{}` in order to pass correct value,
e.g. `initial_node_count` is a `number` not `string`
@michaellzc michaellzc requested review from a team, Jberlinsky and bharathkkb as code owners October 12, 2022 22:26
@comment-bot-dev
Copy link

@michaellzc
Thanks for the PR! 🚀
✅ Lint checks have passed.

Copy link
Member

@bharathkkb bharathkkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @michaellzc! This seems reasonable. We would likely move to a typed object with optional support at some point.

@bharathkkb bharathkkb merged commit faaee19 into terraform-google-modules:master Oct 26, 2022
CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this pull request Jul 15, 2024
)

`node_pool` variables are a mix of string, bool, number
therefore, it is better to use `map(any)` to indicate its type

moreover, the use of `list(map(string))` is breaking
the use of this module in `cdktf`.

in the generated code it will produce
`[]map[string]string` for `node_pools` option
but we want `[]map[string]interface{}` in order to pass correct value,
e.g. `initial_node_count` is a `number` not `string`

Co-authored-by: Bharath KKB <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants