如何在 terraform 中使用项目范围的 ssh 密钥

Cap*_*her 5 ssh google-cloud-platform terraform

这里有另一篇关于如何将 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}"

}
Run Code Online (Sandbox Code Playgroud)

小智 0

我不确定,但我认为它可能是其中之一,因为我试图弄清楚如何将 ssh 密钥添加到我的项目 https://www.terraform.io/docs/providers/google/r/compute_project_metadata_item .html https://www.terraform.io/docs/providers/google/r/compute_project_metadata.html 希望这会有所帮助