github.com/swisspost/terratest@v0.0.0-20230214120104-7ec6de2e1ae0/examples/packer-basic-example/build-gcp.pkr.hcl (about)

     1  packer {
     2    required_plugins {
     3      googlecompute = {
     4        version = ">=v1.0.0"
     5        source  = "github.com/hashicorp/googlecompute"
     6      }
     7    }
     8  }
     9  
    10  variable "gcp_project_id" {
    11    type    = string
    12    default = ""
    13  }
    14  
    15  variable "gcp_zone" {
    16    type    = string
    17    default = "us-central1-a"
    18  }
    19  
    20  source "googlecompute" "ubuntu-bionic" {
    21    image_family        = "terratest"
    22    image_name          = "terratest-packer-example-${formatdate("YYYYMMDD-hhmm", timestamp())}"
    23    project_id          = var.gcp_project_id
    24    source_image_family = "ubuntu-1804-lts"
    25    ssh_username        = "ubuntu"
    26    zone                = var.gcp_zone
    27  }
    28  
    29  
    30  build {
    31    sources = [
    32      "source.googlecompute.ubuntu-bionic"
    33    ]
    34  
    35    provisioner "shell" {
    36      inline       = ["sudo DEBIAN_FRONTEND=noninteractive apt-get update", "sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y"]
    37      pause_before = "30s"
    38    }
    39  
    40  }