Node.js Google云计算引擎API:createVM直接使用setMetadata
我使用@googlecloud/compute自动创建VM实例 我还在这些实例中使用启动脚本 所以,我先打电话,然后 但在某些地区,启动脚本没有运行。它是在虚拟机重置后运行的,所以看起来我的电话太迟了 在web界面中,我们可以直接使用元数据创建VM。但我在API中看不到这种能力Node.js Google云计算引擎API:createVM直接使用setMetadata,node.js,google-compute-engine,Node.js,Google Compute Engine,我使用@googlecloud/compute自动创建VM实例 我还在这些实例中使用启动脚本 所以,我先打电话,然后 但在某些地区,启动脚本没有运行。它是在虚拟机重置后运行的,所以看起来我的电话太迟了 在web界面中,我们可以直接使用元数据创建VM。但我在API中看不到这种能力 可以使用API完成吗?要在实例部署期间设置启动脚本,可以将其作为API调用中元数据属性的一部分提供: POST https://www.googleapis.com/compute/v1/projects/myproje
可以使用API完成吗?要在实例部署期间设置启动脚本,可以将其作为API调用中元数据属性的一部分提供:
POST https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances
{
...
"metadata": {
"items": [
{
"key": "startup-script",
"value": "#! /bin/bash\n\n# Installs apache and a custom homepage\napt-get update\napt-get install -y apache2\ncat <<EOF > /var/www/html/index.html\n<html><body><h1>Hello World</h1>\n<p>This page was created from a simple start up script!</p>\n</body></html>"
}
]
}
...
}
"metadata": {
"items": [
{
"key": "startup-script-url",
"value": "gs://bucket/myfile"
}
]
},