...
1variable "project_id" {
2 type = string
3 default = "ret-edge-pltf-infra"
4}
5
6variable "zone" {
7 type = string
8 default = "us-east1-b"
9}
10
11variable "image_description" {
12 type = string
13 default = "Base image for Edge CI runner machines"
14}
15
16variable "source_image_family" {
17 type = string
18 // default = "gsre-base-ubuntu-2204" // either deprecated or abandoned
19 default = "ubuntu-2204-lts"
20}
21
22variable "source_image" {
23 type = string
24 default = ""
25}
26
27variable "source_image_project_id" {
28 type = list(string)
29 default = ["ubuntu-os-cloud", "gsre-compute-images-prod"]
30}
31
32locals {
33 timestamp = regex_replace(timestamp(), "[- TZ:]", "")
34}
35
36source "googlecompute" "golden-image-ubuntu-2204" {
37 project_id = var.project_id
38 impersonate_service_account = "golden-image-generation@ret-edge-pltf-infra.iam.gserviceaccount.com"
39 service_account_email = "golden-image-generation@ret-edge-pltf-infra.iam.gserviceaccount.com"
40
41 image_description = var.image_description
42 image_name = "edge-runner-${local.timestamp}"
43 image_family = "edge-runner"
44 source_image_family = var.source_image_family
45 source_image = var.source_image
46 source_image_project_id = var.source_image_project_id
47 zone = var.zone
48 machine_type = "n2-standard-16"
49 disk_size = 256
50
51 ssh_username = "packer"
52 communicator = "ssh"
53 use_iap = true
54 use_internal_ip = true
55 use_os_login = false
56 omit_external_ip = true
57 temporary_key_pair_type = "ed25519"
58
59 scopes = [
60 "https://www.googleapis.com/auth/cloud-platform",
61 ]
62}
63
64build {
65 sources = ["sources.googlecompute.golden-image-ubuntu-2204"]
66
67 provisioner "file" {
68 source = "${path.root}/startup_script.sh"
69 destination = "/tmp/startup_script.sh"
70 }
71
72 provisioner "file" {
73 source = "${path.root}/shutdown_script.sh"
74 destination = "/tmp/shutdown_script.sh"
75 }
76
77 provisioner "shell" {
78 script = "${path.root}/setup_script.sh"
79 expect_disconnect = true
80 // 2300218 allows for disconnect causes by reboot during setup
81 valid_exit_codes = [0, 2300218]
82 }
83}
View as plain text