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

Fixes pod_security_policy_config type issue #408

Merged
merged 2 commits into from
Jan 27, 2020

Conversation

kri5
Copy link
Contributor

@kri5 kri5 commented Jan 27, 2020

When attempting to use the variable pod_security_policy_config, as it has no specified type,
terraform interpret it has string, leading to errors such as

Error: Invalid dynamic for_each value

  on cluster.tf line 80, in resource "google_container_cluster" "primary":
  80:     for_each = var.pod_security_policy_config
    |----------------
    | var.pod_security_policy_config is "[{\"enabled\":true}]"

As it expects a list of map, i specified the type accordingly.
I used any for the value type inside the map for future-proof reason.

Feel free to comment!

Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, one suggestion.

@@ -406,6 +406,7 @@ variable "enable_binary_authorization" {
}

variable "pod_security_policy_config" {
type = list(map(string))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think an object would be better actually.

Suggested change
type = list(map(string))
type = list(object({ enabled = bool }))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just updated the PR accordingly, wasn't sure about how strong the constraint should be :)

This fixes an issue where type defaults to string, and leads to
a type error attempting to set the value from outside the module.
@morgante morgante merged commit a99352a into terraform-google-modules:master Jan 27, 2020
CPL-markus pushed a commit to WALTER-GROUP/terraform-google-kubernetes-engine that referenced this pull request Jul 15, 2024
…orm-google-modules#408)

* Specify type for pod_security_policy_config

This fixes an issue where type defaults to string, and leads to
a type error attempting to set the value from outside the module.

* Generate modules following the changes to pod_security_policy_config
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.

None yet

2 participants