使用创建实例
gcloud compute instances create ...snip
... --metadata empty="",short="foo",long="thirty six character long string bla" ...
然后,在实例上,使用检索元数据
curl
"http://metadata.google.internal/computeMetadata/v1/instance/attributes/file-name"
-H "Metadata-Flavor: Google" -silent
我们最终使用
empty = X-Frame-Options: SAMEORIGINlock GMT
short = foorame-Options: SAMEORIGINlock GMT
long = thirty six character long string bla
我不确定这是cURL、谷歌云的一个怪癖,还是当你通过http提供一个极短的字符串时会发生什么。
原来我传递了-silent而不是-silent作为curl的另一个arg,这会破坏输出。