当我通过SSH或控制台登录到Terraform创建的Debian或Ubuntu VM时,出现提示,但无法登录。
我还尝试了Google Cloud命令行(gcloudcompute ssh INSTANCe_ID --zone us-east1-b“),但这与Terraform创建的VM不兼容,与我手动创建的VM不同(这使我直接扎根)。
resource "google_compute_instance" "web-server" {
name = "web-server"
machine_type = "g1-small"
zone = "${var.zone}"
metadata_startup_script = "echo hi > /test.txt"
service_account {
email = "${data.google_compute_default_service_account.default.email}"
scopes = ["https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring.write",
"https://www.googleapis.com/auth/pubsub",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/trace.append"]
}
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1804-lts"
}
}
network_interface {
subnetwork = "${google_compute_subnetwork.protected-subnet.self_link}"
network_ip = "10.10.2.10"
access_config {
network_tier = "STANDARD"
}
}
scheduling {
preemptible = true
automatic_restart = false
}
metadata = {
serial-port-enable = "1"
}
}
无错误消息。只是超时或登录尝试失败。