While creating a VM instance, I can add some (optionals) metadata that can be reached by doing:
curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/attributes/
On the other hand, we can also define sort of global metadata values on
https://console.cloud.google.com/compute/metadata?project=xxx, which can be reached by doing:
curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/project/attributes/
/project one seems to be a global metadata shared for all the instances in the project, and the
/instance seems to be metadata attached only to the current instance. Besides that, is there any other difference?
I was doing the
GCS & GCE Challenge Lab and I set the metadata (the bucket name to storage the startup log) in the global metadata, due to I thought about that bucket as the global bucket to storage every log.
If we define that the created bucket is gonna be used in every single instance to log things, so, is it OK to define it as a global metadata for all the instances?
Excellent questions, Broda! It’s very good to be thinking all of this through, like this.
To answer your key questions: These two forms of metadata work exactly the same way, with only the differences you’ve called out. So you can definitely choose to specify the metadata in the project spot instead of on each instance–but you’ll then have to tweak the startup script I’ve given you, because it only looks for the information at the instance-level metadata address. I encourage you to try it out! 😀👍