If I pass in user data like so:
$ cat cfg #/bin/sh touch /tmp/foobar
$ gcloud compute instances create aa-$(date +%y%m%d-%H%M) --image-family ubuntu-1710 --image-project ubuntu-os-cloud-devel --metadata-from-file user-data=cfg ...
Then in the instance:
$ ls /tmp/foobar $ sudo cat /var/lib/cloud/instance/user-data.txt $ curl "http://metadata.google.internal/computeMetadata/v1/instance/attributes/user-data" -H "Metadata-Flavor: Google" #/bin/sh touch /tmp/foobar
If I pass in user data like so:
$ cat cfg
#/bin/sh
touch /tmp/foobar
$ gcloud compute instances create aa-$(date +%y%m%d-%H%M) --image-family ubuntu-1710 --image-project ubuntu- os-cloud- devel --metadata- from-file user-data=cfg
...
Then in the instance:
$ ls /tmp/foobar cloud/instance/ user-data. txt metadata. google. internal/ computeMetadata /v1/instance/ attributes/ user-data" -H "Metadata-Flavor: Google"
$ sudo cat /var/lib/
$ curl "http://
#/bin/sh
touch /tmp/foobar