I'm currently trying to manipulate the metadata of my instance from the startup-script. To do that I have to use the following command :
gcutil setinstancemetadata <instance-name> --metadata=<key-1:value-1> --fingerprint=<current-fingerprint-hash>
As you can see the command ask for the instance-name. For I tried to get it from the metadata, but it was not there (see : Default Metadata).
My question is how to get this instance name ?
Edit: For now my only solution is to add the instance-name as a metadata when I create the instance :
gcutil addintance my-cool-instance --metadata=instance-name:my-cool-instance
And then get it with a curl request :
curl 'http://metadata/computeMetadata/v1/instance/attributes/instance-name' -H "X-Google-Metadata-Request: True"