variable "project_id" { type = string default = "ret-edge-pltf-infra" } variable "zone" { type = string default = "us-east1-b" } variable "image_description" { type = string default = "Base image for Edge CI runner machines" } variable "source_image_family" { type = string // default = "gsre-base-ubuntu-2204" // either deprecated or abandoned default = "ubuntu-2204-lts" } variable "source_image" { type = string default = "" } variable "source_image_project_id" { type = list(string) default = ["ubuntu-os-cloud", "gsre-compute-images-prod"] } locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") } source "googlecompute" "golden-image-ubuntu-2204" { project_id = var.project_id impersonate_service_account = "golden-image-generation@ret-edge-pltf-infra.iam.gserviceaccount.com" service_account_email = "golden-image-generation@ret-edge-pltf-infra.iam.gserviceaccount.com" image_description = var.image_description image_name = "edge-runner-${local.timestamp}" image_family = "edge-runner" source_image_family = var.source_image_family source_image = var.source_image source_image_project_id = var.source_image_project_id zone = var.zone machine_type = "n2-standard-16" disk_size = 256 ssh_username = "packer" communicator = "ssh" use_iap = true use_internal_ip = true use_os_login = false omit_external_ip = true temporary_key_pair_type = "ed25519" scopes = [ "https://www.googleapis.com/auth/cloud-platform", ] } build { sources = ["sources.googlecompute.golden-image-ubuntu-2204"] provisioner "file" { source = "${path.root}/startup_script.sh" destination = "/tmp/startup_script.sh" } provisioner "file" { source = "${path.root}/shutdown_script.sh" destination = "/tmp/shutdown_script.sh" } provisioner "shell" { script = "${path.root}/setup_script.sh" expect_disconnect = true // 2300218 allows for disconnect causes by reboot during setup valid_exit_codes = [0, 2300218] } }