Skip to content

Instantly share code, notes, and snippets.

@jbielick
Created February 22, 2021 23:37
Show Gist options
  • Save jbielick/8a6c82bf0ce82d71ee7902751af10222 to your computer and use it in GitHub Desktop.
Save jbielick/8a6c82bf0ce82d71ee7902751af10222 to your computer and use it in GitHub Desktop.
source "googlecompute" "sftp" {
project_id = "my-project"
source_image_family = "debian-10"
ssh_username = "packer"
machine_type = "n1-standard-2"
disk_size = 50
zone = "us-east1-d"
subnetwork = "default"
image_name = "sftp-{{timestamp}}"
}
build {
sources = ["sources.googlecompute.sftp"]
provisioner "file" {
source = "files/hostkeys.tar.gz"
destination = "/tmp/hostkeys.tar.gz"
}
provisioner "shell" {
execute_command = "echo 'packer' | sudo -S env {{ .Vars }} {{ .Path }}"
inline = [
"tar -zxpf /tmp/hostkeys.tar.gz --directory /etc/ssh/",
"chown -R root:root /etc/ssh/"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment