Open AlexPykavy opened 2 months ago
Hi @AlexPykavy I tried to replicate this scenario with the shared terraform version and Google provider version, and with your code and the terraform registry code. But the result was correct, returning the next error:
Error creating instance: googleapi: Error 400: Invalid value for field 'resource.name' "super-long-machine-name-that-does-not-meet-the-google-compute-instance-naming-restrictions". Must be a match of regex '(?:[a-z](?:[a-z0-9]{0,61}[a-z0-9])?)', invalid
I suggest you refresh your environment and make basic troubleshooting to release memory and cache and try again. A terraform init
or terraform init -upgrade
could also work.
Hi @ggtisc ,
Thank you for the quick response. Did you receive this error during the terraform plan
or the terraform apply
?
After a double check terraform apply
works with an expected behavior, but terraform plan
doesn't recognize the error for the long name.
Based on this I'm forwarding this as an enhancement proposal.
Note from triage: We'd want to check for any history of compute instance names being validated in the provider and discovering edge cases before adding this
Community Note
Terraform Version & Provider Version(s)
Terraform v1.7.1 on windows_amd64
Affected Resource(s)
google_compute_instance
Terraform Configuration
Debug Output
No response
Expected Behavior
terraform plan
fails with a meaningful messageActual Behavior
terraform plan
passesSteps to reproduce
terraform plan
terraform apply
Important Factoids
No response
References
I've tried to fix it in the https://github.com/GoogleCloudPlatform/magic-modules/pull/10775.
b/343730710