AWS AMIs with Packer

Builds Amazon Machine Images with Packer's amazon-ebs builder from a ready HCL template, with source filters, multi-region copies, credentials and fixes for common build errors. Use when creating a custom AMI for EC2.

DevOpsPack: HashiCorp skillslinkaws-ami-builder
Author
Source
hashicorp/agent-skills/plugins/packer/skills/aws-ami-builder @ 5e30fa5
License
MPL-2.0

About this skill

What it does

The skill is a short reference for building Amazon Machine Images with Packer's amazon-ebs builder. Its core is one complete HCL template: a packer block requiring the Amazon plugin ~> 1.3, a region variable, a timestamp local that keeps AMI names unique, a source "amazon-ebs" that picks the latest Ubuntu 22.04 image from Canonical's owner ID on a t3.micro, tags, and a build block with a shell provisioner that updates packages.

It adds a source filter for Amazon Linux 2023, copying the finished image to other regions with ami_regions, the order in which Packer finds AWS credentials (environment variables, ~/.aws/credentials, an instance profile on EC2), and the commands packer init, packer validate and packer build. Three common failures get a fix each: SSH timeouts (security group port 22, a subnet with internet access), an AMI name that already exists, and a root volume too small for the source image (launch_block_device_mappings). A note warns that builds cost money for EC2, EBS and data transfer and take 10 to 30 minutes. The folder holds only SKILL.md.

When to use it, and when not

Use it for a first Packer template for a Linux AMI, or when a build fails with one of the three errors above. You need the Packer CLI and AWS credentials that may launch instances.

The skill stops at the basics: no encryption settings, IAM permissions for Packer, Ansible provisioners or clean-up of old AMIs. Windows images, Azure images and the HCP Packer registry have their own skills in HashiCorp's packer plugin (windows-builder, azure-image-builder, push-to-registry), which our catalog does not list.

How to run it

We do not copy this skill: its files are under MPL-2.0, a file-level copyleft licence outside the set we copy under. Install it from HashiCorp's repository with the button to the source: one skill via npx skills add hashicorp/agent-skills/plugins/packer/skills/aws-ami-builder, or the whole packer plugin with four skills via claude plugin marketplace add hashicorp/agent-skills, then claude plugin install packer@hashicorp. In Codex: codex plugin marketplace add hashicorp/agent-skills, then install packer from /plugins and start a new session. In Claude Code, the plugin's skill may appear as /packer:aws-ami-builder.

  • Claude Code: /aws-ami-builder, or ask for the skill by name.
  • Codex: $aws-ami-builder.
  • Cursor: type / in the Agent chat and pick aws-ami-builder.

Example: /aws-ami-builder Write a Packer template for an Amazon Linux 2023 AMI with nginx installed, copied to eu-west-1.

How it differs from similar skills

The catalog has nothing else for Packer or virtual machine images. The nearest skills build containers: Dockerfile build strategies and Dockerfile review deal with multi-stage builds, layer caching and non-root users in Docker images, not machine images.

Install

This skill is not copied to the catalog: its licence allows a copy only under the same licence, and the catalog does not copy under such licences. Install it from the author's repository.

Open the source

Connect through AnyModel API

This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.

More from the pack HashiCorp skills

Terraform style guide

Applies HashiCorp's Terraform style conventions: standard file split, formatting, naming, typed variables, for_each over count, pinned versions and secrets kept out of state. Use when writing, reviewing or generating Terraform HCL.

Terraform tests

Writes and runs Terraform's native tests in .tftest.hcl files: run blocks, assertions, plan and apply modes, expect_failures, mock providers and CI pipelines. Use when adding tests to a Terraform module or fixing a failing terraform test.

Terraform Stacks

Writes Terraform Stacks configurations for HCP Terraform: components in .tfcomponent.hcl, deployments in .tfdeploy.hcl, OIDC identity tokens, auto-approve rules, linked Stacks and API monitoring. Use when building or debugging a Stack.

Refactor Terraform into modules

Splits a monolithic Terraform configuration into a reusable module with a typed interface, then migrates state with moved blocks or terraform state mv so nothing is recreated. Use when a root config has grown too large or repeats itself.

Terraform search and import

Finds existing cloud resources with Terraform Search queries in .tfquery.hcl, generates resource and import blocks, and falls back to manual import for unsupported types. Use when bringing hand-made infrastructure under Terraform.

Terraform policy files

Writes, converts and tests HCP Terraform policy files (.policy.hcl, .policytest.hcl), including Sentinel-to-tfpolicy conversion with a quality label per policy. Use when writing a new policy, porting Sentinel or debugging a policy test.

Azure Verified Modules for Terraform

Applies the 37 Azure Verified Modules requirements to Terraform modules: provider versions, sources, naming, variables, outputs, breaking changes and repository rules. Use when writing or reviewing an Azure module meant for AVM certification.

Terraform provider resources

Guides writing Terraform provider resources and data sources on the Plugin Framework: schema, CRUD, not-found handling, import, waiters for eventually consistent APIs and minimum tests. Use when adding, changing or reviewing a provider resource.

Terraform provider test patterns

Covers acceptance tests for Terraform providers with terraform-plugin-testing: test steps, state and plan checks, import, disappears and regression tests, sweepers and ephemeral resources. Use when writing, reviewing or debugging provider acceptance tests.