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

feat: add validation checks when using existing KSA #1567

Conversation

loremaps
Copy link

See #1065

This PR adds checks for cluster_name and location variables, when using an existing KSA.

The error message is not great:

╷
│ Error: Invalid function argument
│
│   on ../../../../../personal/terraform-google-kubernetes-engine/modules/workload-identity/main.tf line 33, in locals:
│   33:   validate_cluster = (var.use_existing_k8s_sa && var.cluster_name == "") ? tobool("Variable 'cluster_name' is required when using existing KSA") : true
│     ├────────────────
│     │ while calling tobool(v)
│
│ Invalid value for "v" parameter: cannot convert "Variable 'cluster_name' is required when using existing KSA" to bool; only the strings "true" or "false" are allowed.
╵

But I was bitten by this issue two times already. I believe that this does give some guidance. But if you feel the error is too misleading, please feel free to close this PR 😅

This was the simplest solution I could find until hashicorp/terraform#25609 or hashicorp/terraform#31122 are addressed. Taken from here

Thank you for your time reviewing!

@loremaps loremaps requested review from a team, Jberlinsky and ericyz as code owners February 18, 2023 14:23
@google-cla
Copy link

google-cla bot commented Feb 18, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@bharathkkb
Copy link
Member

/gcbrun

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 for the PR @loremaps
I think the tobool workaround is a bit confusing. Could we update the documentation instead?

@loremaps
Copy link
Author

Hey @bharathkkb thanks for reviewing.

Indeed it is and please feel free to close this PR.

The documentation was updated in #1143 AFAIK to help us avoid this misconfiguration.

But if you miss the docs, please compare the error message shown in #1065 and that of the tobool workaround. And then you have to manually remove from state to recover (see #1065 (comment))

Once again, thanks for your time and feel free to close this, np!

@bharathkkb
Copy link
Member

Thanks @loremaps

@bharathkkb bharathkkb closed this Apr 13, 2023
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