packer - cirelledo-csa/herd GitHub Wiki

Packer

Packer is an automation tool that builds images. Written in go and able to create a wide variety of virtual images including AWS amis. Packer uses templates to build machine images.

  • packer binaries

  • install packer:

    curl -o packer.zip https://releases.hashicorp.com/packer/1.3.4/packer_1.3.4_linux_amd64.zip
    unzip packer.zip
    
  • base your images on the latest AWS Amazon Linux 2 ami

  • Amazon owner is

    aws ec2 describe-images --image-id `aws ec2 describe-images --owners amazon --filters 'Name=name,Values=amzn2-ami-hvm-2.0.????????-x86_64-gp2' 'Name=state,Values=available' --output json | jq -r '.Images | sort_by(.CreationDate) | last(.[]).ImageId'` | jq -r .Images[].OwnerId
    137112412989
    

    therefore to use the latest AWS Amazon Linux 2 ami, your packer template should have something that looks like:

      "source_ami_filter": {
        "filters": {
          "name": "amzn2-ami-hvm-2.0.????????-x86_64-gp2",
          "root-device-type": "ebs",
          "virtualization-type": "hvm"
        },
        "most_recent": true,
        "owners": [
          "137112412989"
        ]
      },