ruk·si

Packer
Prefetched Docker Images

Updated at 2018-02-06 18:06
{
  "variables": {
    "aws_access_key": "",
    "aws_secret_key": "",
    "region": "eu-west-1",
    "instance_type": "t2.medium"
  },
  "builders": [
    {
      "type": "amazon-ebs",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "region": "{{user `region`}}",
      "iam_instance_profile": "PotatoInstanceRole",
      "source_ami": "ami-d8f4deab",
      "instance_type": "{{user `instance_type`}}",
      "ssh_username": "ubuntu",
      "ami_name": "Packer-Potato-{{user `instance_type`}}-{{timestamp}}",
      "launch_block_device_mappings": [
        {
          "device_name": "/dev/sda1",
          "volume_size": 40,
          "volume_type": "gp2",
          "delete_on_termination": true
        }
      ]
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'",
      "inline": [
        "apt-get update --fix-missing",
        "apt-get install -y --no-install-recommends git awscli docker",
        "apt-get clean",
        "apt-get autoremove",
        "rm -rf /var/lib/apt/lists/*"
      ]
    },
    {
      "type": "shell",
      "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'",
      "inline": [
        "docker pull consul",
        "docker pull postgres"
      ]
    }
  ]
}
packer build prefetched-instance.json