【问题标题】:Unable to fetch ZONE from the Cloud Shell instance无法从 Cloud Shell 实例获取 ZONE
【发布时间】:2020-06-01 00:34:17
【问题描述】:

我想获取 Cloud Shell 虚拟机实例所在的区域,我创建了这个自定义脚本来通过元数据服务器获取区域;但是它不起作用。我可能缺少什么(我知道如果我要从普通 VM 实例执行此操作,我必须启用对元数据服务器的 API 访问)

#! /bin/bash
ZONE=$(curl -s http://metadata.google.internal/computeMetadata/v1/instance/ -H "Metadata-Flavor: Google")
echo $ZONE

【问题讨论】:

    标签: google-cloud-platform google-compute-engine google-cloud-shell


    【解决方案1】:

    要查看您的 Cloud Shell 所在的区域,您可以运行以下命令:

    curl -H "Metadata-Flavor: Google" metadata/computeMetadata/v1/instance/zone
    

    您可能希望将此用作脚本的参考或直接使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多