这里有另一篇关于如何将 ssh 密钥添加到您的 terraform 实例的帖子。但是,我的问题是如何在 terraform 中使用项目范围的 ssh 密钥?
/*CREATE INSTANCE TEMPLATE*/
resource "google_compute_instance_template" "template-030601" {
name = "terraform-template-030601"
description = "This template is used to create app server instances."
tags = ["foo", "bar"]
labels = {
environment = "sbx"
}
instance_description = "description assigned to instances"
machine_type = "f1-micro"
can_ip_forward = false
//Create a new boot disk from an image
disk {
source_image = "https://www.googleapis.com/compute/v1/projects/hp-img-cof-st-core-prd/global/images/cof-ubuntu1604-180124"
auto_delete = false
boot = true
}
network_interface {
subnetwork = "${var.subnet}"
subnetwork_project = …Run Code Online (Sandbox Code Playgroud)