2
votes

seokwoong_chang@cellular-hold-144901:~$ gcloud compute ssh --quiet \

--project "cellular-hold-144901" \ --zone "asia-east1-a" \ --ssh-flag="-N" \ --ssh-flag="-L" \ --ssh-flag="localhost:8081:localhost:8080" \ "${USER}@${USER}-datalab-server" ERROR: (gcloud.compute.ssh) Could not fetch instance: - Invalid value 'seokwoong_chang-datalab-server'. Values must match the following regular expression: 'a-z?'

seokwoong_chang@cellular-hold-144901:~$

2

2 Answers

2
votes

Note that the suggested naming convention is simply a suggestion, not a requirement.

You can name your Datalab VM anything you'd like, rather than use your user name. This is especially interesting, if you happen to share the VM across users. For example, you might use team name or some other qualifier as appropriate to produce a unique name.

1
votes

Can you try replacing $USER with ${USER//[_]/-} so that the underscore is replaced with a -?

Please note that you need to run the glcoud compute instances create... command first:

gcloud compute instances create "${USER//[_]/-}-datalab-server" \
  --project "project-id" \
  --zone "zone" \
  --network "datalab-network" \
  --image-family "container-vm" \
  --image-project "google-containers" \
  --metadata "google-container-manifest=$(cat datalab-server.yaml)" \
  --machine-type "n1-highmem-2" \
  --scopes "cloud-platform"

Followed by:

gcloud compute ssh --quiet \
  --project "project-id" \
  --zone "zone" \
  --ssh-flag="-N" \
  --ssh-flag="-L" \
  --ssh-flag="localhost:8081:localhost:8080" \
  "${USER//[_]/-}@${USER//[_]/-}-datalab-server"