---
name: "packer-hcl2-golden-ami"
description: "Build immutable, pre-baked Golden AMIs and VM images for AWS, GCP, and Azure using Packer."
metadata:
  author: "HashiCorp"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "build golden ami packer hcl2"
  - "provision packer with ansible"
  - "validate packer template"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# HashiCorp Packer HCL2 Golden Image Pipeline

Builds golden machine images with Packer HCL2: amazon-ebs builder, provisioners (shell, ansible), post-processors, hardening CIS baselines, scanning with OpenSCAP, and automated AMI sharing.

## When to Invoke
Invoke this skill whenever you need to:
- build golden ami packer hcl2
- provision packer with ansible
- validate packer template

## Execution SOP & Rules
1. Define source 'amazon-ebs' 'ubuntu' block specifying instance_type, source_ami_filter, and vpc_id.
2. Add build block with provisioner 'ansible' or provisioner 'shell'.
3. Validate configuration syntax: packer validate -var-file=vars.pkrvars.hcl template.pkr.hcl.
4. Execute build: packer build -var-file=vars.pkrvars.hcl template.pkr.hcl.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
