github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/e2e/terraform/packer/ubuntu-bionic-amd64.pkr.hcl (about)

     1  variable "build_sha" {
     2    type        = string
     3    description = "the revision of the packer scripts building this image"
     4  }
     5  
     6  locals {
     7    timestamp = regex_replace(timestamp(), "[- TZ:]", "")
     8    distro    = "ubuntu-bionic-18.04-amd64-server-*"
     9    version   = "v2"
    10  }
    11  
    12  source "amazon-ebs" "latest_ubuntu_bionic" {
    13    ami_name             = "nomad-e2e-${local.version}-ubuntu-bionic-amd64-${local.timestamp}"
    14    iam_instance_profile = "packer_build" // defined in nomad-e2e repo
    15    instance_type        = "t2.medium"
    16    region               = "us-east-1"
    17    ssh_username         = "ubuntu"
    18  
    19    source_ami_filter {
    20      filters = {
    21        architecture                       = "x86_64"
    22        "block-device-mapping.volume-type" = "gp2"
    23        name                               = "ubuntu/images/hvm-ssd/${local.distro}"
    24        root-device-type                   = "ebs"
    25        virtualization-type                = "hvm"
    26      }
    27      most_recent = true
    28      owners      = ["099720109477"] // Canonical
    29    }
    30  
    31    tags = {
    32      OS         = "Ubuntu"
    33      Version    = "Bionic"
    34      BuilderSha = var.build_sha
    35    }
    36  }
    37  
    38  build {
    39    sources = ["source.amazon-ebs.latest_ubuntu_bionic"]
    40  
    41    provisioner "file" {
    42      destination = "/tmp/linux"
    43      source      = "./ubuntu-bionic-amd64"
    44    }
    45  
    46    // cloud-init modifies the apt sources, so we need to wait
    47    // before running our setup
    48    provisioner "shell-local" {
    49      inline = ["sleep 30"]
    50    }
    51  
    52    provisioner "shell" {
    53      script = "./ubuntu-bionic-amd64/setup.sh"
    54    }
    55  }