Skip to content
Menu
myCloud myCloud

Personal short notes about Cloud

  • XMPie
  • AWS
    • AWS Topics
    • AWS Architecture
    • AWS CLI
    • AWS Health
    • AWS Policies
    • AWS Cost
  • CHEAT SHEETS
myCloud myCloud

Personal short notes about Cloud

Hashicorp Packer

By mikado on October 24, 2022October 24, 2022

Packer lets you create identical machine images for multiple platforms from a single source configuration.

Packer can create golden images to use in image pipelines.

https://developer.hashicorp.com/packer/tutorials/aws-get-started/aws-get-started-build-image

Install

choco install packer

Write Packer template

Create a fileĀ aws-ubuntu.pkr.hcl

packer {
  required_plugins {
    amazon = {
      version = ">= 0.0.2"
      source  = "github.com/hashicorp/amazon"
    }
  }
}

source "amazon-ebs" "ubuntu" {
  ami_name      = "learn-packer-linux-aws"
  instance_type = "t2.micro"
  region        = "us-west-2"
  source_ami_filter {
    filters = {
      name                = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"
      root-device-type    = "ebs"
      virtualization-type = "hvm"
    }
    most_recent = true
    owners      = ["099720109477"]
  }
  ssh_username = "ubuntu"
}

build {
  name    = "learn-packer"
  sources = [
    "source.amazon-ebs.ubuntu"
  ]
}

Category: Terraform

Categories

  • AWS (4)
  • AWS Architecture (8)
  • AWS CLI (5)
  • AWS Cost (3)
  • AWS Health (4)
  • AWS Policies (2)
  • AWS Topics (24)
  • CHEAT SHEETS (16)
  • Container (21)
  • Datadog (4)
  • Jenkins (2)
  • Linux (9)
  • Microsoft (7)
  • Python (1)
  • SCRIPTS (9)
  • Terraform (5)
  • XMPie (6)
©2025 myCloud
Click to Copy