terraform-provider-google
terraform-provider-google copied to clipboard
Validate BigQuery naming requirements before apply
Description
Plan shows resources will be created but then it fails during apply.
Error: Error creating Dataset: googleapi: Error 400: Invalid dataset ID "my-table". Dataset IDs must be alphanumeric (plus underscores) and must be at most 1024 characters long., invalid
It'd be more productive if Terraform would validate that the names satisfy the requirements before applying.
New or Affected Resource(s)
- google_bigquery_*
Here is an example of a workflow that the lack of validation "enables":
- Work on changes locally (write code, plan, plan, plan)
- Submit PR
- CI shows same plan that you had locally
- Request reviews
- Get approvals
- CI tries to apply the change and fails
- Troubleshoot issue
- Update PR -> Approvals are invalidated
- Request reviews
- Get approvals
- CI applies changes
This isn't something the google terraform provider has native support for, I'd recommend defining your validation rules on an input variable instead: https://www.terraform.io/language/values/variables#custom-validation-rules. Or if you want to go even further than that, there is a terraform provider for jsonschema validation - which also does a good job of creating custom enforced rules: https://registry.terraform.io/providers/JeffAshton/jsonschema/latest/docs
I don't know about the validation rules. Is there a document detailing everything? Otherwise, I'd have to go the trial and error route which is what we already are doing with all the failures in CI.
I'd think the provider is a better chokepoint to implement this kind of validation.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.