Skip to content

Instantly share code, notes, and snippets.

@steinbrueckri
Last active August 13, 2019 18:38
Show Gist options
  • Save steinbrueckri/f519f39078bec0a306c983dd8e13821b to your computer and use it in GitHub Desktop.
Save steinbrueckri/f519f39078bec0a306c983dd8e13821b to your computer and use it in GitHub Desktop.
Deploy πŸš€ SSH πŸ”‘ via Terraform #terraform #ssh #deploy
# ssh key via variable
resource "google_compute_instance" "via-variable" {
name = "via-variable"
machine_type = "n1-standard-1"
zone = "europe-west4-a"
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
// Local SSD disk
scratch_disk {
}
network_interface {
network = "default"
access_config {
// Ephemeral IP
}
}
metadata = {
sshKeys = "${var.ssh_key_pub}"
enable-oslogin = "FALSE" # to be sure OS Login is disabled for this instance
}
}
# ssh key via file
resource "google_compute_instance" "via-file" {
name = "via-file"
machine_type = "n1-standard-1"
zone = "europe-west4-a"
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
// Local SSD disk
scratch_disk {
}
network_interface {
network = "default"
access_config {
// Ephemeral IP
}
}
metadata = {
sshKeys = "ansible:${file("./files/ssh_key.pub")}"
enable-oslogin = "FALSE" # to be sure OS Login is disabled for this instance
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment