terraform-dcos
terraform-dcos copied to clipboard
"Invalid value for field 'resource.name'" if username contains "." character
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.
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.