GCP Custom Image
Bake a googlecompute custom image from ubuntu-2404-lts-amd64 on e2-small, prove it with gcloud, then delete the image and leftover disks.
Lab Overview
This is the hands-on lab for Section 8 of Packer 101. You write a googlecompute template that builds from Canonical's Ubuntu 24.04 LTS family in ubuntu-os-cloud, launches an e2-small builder in us-east1-b with a public IP (no IAP), provisions a marker file with a shell provisioner, and registers a uniquely named custom image in family packer-101-lab stored in us-east1 (image_storage_locations). You intentionally break the template, read the validate error, and fix it. After the bake you prove the image with gcloud compute images describe. Cleanup deletes the custom image and any leftover Packer disks so failed or completed builds do not leak cost.
You will:
- Confirm Packer 1.16.0 and GCP identity on the lab host
- Write gcp-ubuntu.pkr.hcl with required_plugins googlecompute ~> 1 and the
locked Ubuntu 24.04 family pins
- Run packer init, fmt, and validate, then recover from a deliberate family
and communicator mistake
- Build the image, prove it with gcloud compute images describe
- Delete the custom image and leftover disks
What You'll Learn
Confirm Packer 1.16.0 and GCP identity on the packer-host lab VM
Author a googlecompute HCL2 template with ubuntu-2404-lts-amd64 and source_image_project_id
Run packer init, fmt, and validate, and recover from a validate failure
Build a custom image and prove it with gcloud compute images describe
Delete the custom image and leftover Packer disks
Prerequisites
Completion of the Packer 101 Section 8 lessons on googlecompute
Basic Linux command line (bash, reading logs)
Basic GCP vocabulary (project, zone, image, family)
Technologies Covered
Part of a Course
This lab is part of the Packer 101 — Golden Images for AWS, Azure, and GCP course
View All CoursesChoose your plan
Simple, Transparent Pricing
Unlock full access to TeKanAid courses, labs, and bootcamps
Just exploring? Start free below. Want the full experience? Try Premium free for 7 days (card required, $0 today).
Pro
All courses, with lab scripts to run on your own machine
Renews automatically. Cancel anytime.
Final price verified at checkout.
- Full access to all courses
- Lab scripts to download and run on your own machine (hosted labs not included)
- Progress tracking
- Certificate of completion
- Community access
- Self-paced bootcamps
- Premium puzzle library not included (5 free puzzles available)
- New content access
Premium
Full access, including unlimited hosted labs
Renews automatically. Cancel anytime.
Final price verified at checkout.
- Everything in Pro
- Unlimited hands-on labs, fully hosted on TeKanAid Academy (nothing to set up)
- Full access to the puzzle library
- Lab AI Assistant
- Priority support
Prefer a single course?
Purchase individual courses for a one-time fee of $79. Full access to course content, quizzes, certificates, and community features, lab access is not included.
Browse CoursesJust exploring? Start free, no account needed
Three free ways to start. All bridge into the paid Premium catalog when you're ready.
Not ready to commit? The crash course is email-only. No academy account required.
Ready to Get Started?
Start this hands-on lab and build real-world Platform Engineering skills
Get Access Now