Skip to content

Instantly share code, notes, and snippets.

@nywilken
Created May 22, 2023 19:57
Show Gist options
  • Save nywilken/3f2276c5b202fa42ff14ab8723a5998a to your computer and use it in GitHub Desktop.
Save nywilken/3f2276c5b202fa42ff14ab8723a5998a to your computer and use it in GitHub Desktop.
variable "project" {
type = string
default = "${env("GOOGLE_PROJECT_ID")}"
}
variable "service_account" {
type = string
default = "${env("GOOGLE_APPLICATION_CREDENTIALS")}"
}
variable "zone" {
type = string
default = "us-central1-a"
}
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
source "googlecompute" "autogenerated_1" {
communicator = "ssh"
image_name = "packer-template-tester-${local.timestamp}"
machine_type = "n1-standard-2"
project_id = "${var.project}"
source_image_family = "ubuntu-1804-lts"
use_os_login = true
ssh_username = "packer"
zone = "${var.zone}"
}
build {
sources = ["source.googlecompute.autogenerated_1"]
provisioner "shell" {
execute_command = "sudo -E -S sh '{{ .Path }}'"
inline = ["ls /var/bar"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment