我知道这在控制台中是可能的,但是如何从terraform中的另一个项目初始化引导磁盘映像呢?
到目前为止,这就是我所拥有的,但它指出,它找不到图像:
boot_disk {
initialize_params {
image = "cof-ubuntu1604-180124"
}
}发布于 2018-02-01 09:18:57
您没有为字段“映像”上的磁盘使用正确的地址。
首先,您需要确保您可以从项目中访问映像,请参阅有关共享图像的信息,请参见
然后,您使用的"image“变量必须指向正确的URI。它看起来是这样的:
"selfLink": "projects/ndjanuary-190908/global/images/ffs12354",您可以从Compute中获取该信息,使用"compute.images.get“方法--我的请求如下所示:
GET https://www.googleapis.com/compute/v1/projects/ndjanuary-190908/global/images/ffs12354?key={YOUR_API_KEY}下面是指向相关API资源管理器的链接:
https://developers.google.com/apis-explorer/#search/image/m/compute/v1/compute.images.get
发布于 2018-01-31 23:04:20
图像不是图像名称,而是图像的URI。
data "google_compute_image" "my_image" {
name = "cof-ubuntu1604-180124"
# could also use family = "family-name"
}
resource "google_compute_instance" "default" {
name = "test"
...
boot_disk {
initialize_params {
image = "${data.google_compute_image.my_image.self_link}"
}
}
...
}参考资料:
发布于 2018-02-01 18:26:01
所提供的答案是bOth非常有用,并解决了我的问题。THe对API的使用对于完善正确的URI是非常宝贵的。
https://stackoverflow.com/questions/48552599
复制相似问题