terraform-dcos icon indicating copy to clipboard operation
terraform-dcos copied to clipboard

"Invalid value for field 'resource.name'" if username contains "." character

Open yogeek opened this issue 6 years ago • 1 comments

I had the following error when trying to use this project to create a DCOS cluster on GCP :

terraform apply -var-file desired_cluster_profile.tfvars 
[...]
 google_compute_network.default: 1 error(s) occurred:

* google_compute_network.default: Error creating network: googleapi: Error 400: Invalid value for field 'resource.name': 'guillaume.dupin-tfa0be-dcos-network'. Must be a match of regex '(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)', invalid
[...]

It is because GCP resources are named with the username (returned by the script "whoami.sh") but if this name contains a dot ("."), it is not a valid character in a GCP resource.

Maybe a fix would be to remove dots (and any forbidden character) from the whoami result to avoid such error.

yogeek avatar Mar 20 '18 17:03 yogeek

Thanks @yogeek for filing this. I will go ahead and add this check in GCP and related projects to ensure it provides the valid character.

bernadinm avatar Mar 28 '18 22:03 bernadinm