packer

HashiCorp Packer image building. Use for machine images.

7 stars

Best use case

packer is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

HashiCorp Packer image building. Use for machine images.

Teams using packer should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/packer/SKILL.md --create-dirs "https://raw.githubusercontent.com/G1Joshi/Agent-Skills/main/skills/devops/packer/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/packer/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How packer Compares

Feature / AgentpackerStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

HashiCorp Packer image building. Use for machine images.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Packer

Packer automates the creation of Machine Images (AMI, VMDK, ISO) for multiple platforms from a single configuration. In 2025, **HCL2** is the standard for configuration.

## When to Use

- **Immutable Infrastructure**: Bake your app code into the OS image. Booting a pre-baked AMI is faster than running Ansible on boot.
- **Golden Images**: Create hardened, secure base images for your organization.
- **Multi-Cloud**: Build an AMI for AWS and a VHD for Azure from the same script.

## Quick Start (HCL2)

```hcl
source "amazon-ebs" "ubuntu" {
  ami_name      = "my-app-{{timestamp}}"
  instance_type = "t3.micro"
  region        = "us-west-2"
  source_ami_filter {
    filters = {
      name                = "ubuntu/images/*ubuntu-jammy-22.04-amd64-server-*"
      root-device-type    = "ebs"
      virtualization-type = "hvm"
    }
    most_recent = true
    owners      = ["099720109477"] # Canonical
  }
  ssh_username = "ubuntu"
}

build {
  sources = ["source.amazon-ebs.ubuntu"]

  provisioner "shell" {
    inline = ["sudo apt-get update", "sudo apt-get install -y nginx"]
  }
}
```

## Core Concepts

### Builders

Cloud-specific components (e.g., `amazon-ebs`, `azure-arm`) that launch a VM.

### Provisioners

Tools to configure the VM (Shell, Ansible, Chef) before it is turned into an image.

### Post-Processors

What to do with the image (Upload to S3, Vagrant Box, Docker Push).

## Best Practices (2025)

**Do**:

- **Use HCL2**: JSON templates are legacy. HCL2 supports variables and logic.
- **CI Integration**: Run Packer in CI pipeline to produce new AMIs on every release.
- **Cleanup**: Ensure Packer cleans up temporary resources (Security Groups, Key Pairs) after build.

**Don't**:

- **Don't bake secrets**: Never put passwords in the image. Use Cloud-init or User Data to inject them at runtime.

## References

- [Packer Documentation](https://developer.hashicorp.com/packer)