这里有一个关于如何将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 = "${var.subnet_project}"
}
metadata {
sshKeys =
}
metadata_startup_script = "${data.template_file.install_script.rendered}"
}