A registry for image metadata

What HCP Packer records about every build, how buckets, versions, builds and artifacts fit together, and how ancestry links an image to the image it was built from.

GazeekTERRAFORM AND PACKER: INFRASTRUCTURE AS CODE·LESSON 19
LESSON 19

A registry for image metadata

What HCP Packer records about every build, how buckets, versions, builds and artifacts fit together, and how ancestry links an image to the image it was built from.

0:00 / 3:36

Diagrams in this video · 2Free in archhy

Copy and edit in archhy: What HCP Packer records (new tab)
Copy and edit in archhy: Metadata in the registry, images in the cloud (new tab)

After this lesson you can

  • Explain that HCP Packer stores image metadata, not the images themselves
  • Describe buckets, versions, builds and artifacts and how they nest
  • Describe how a Packer build sends its metadata to the registry
  • Explain what ancestry tracks between parent and child images
Transcript

A registry for image metadata

G'day, Space Llama here. We can bake golden images now. Lovely. But after a few months, you'll have dozens. Which one is current? Which one is in production? What's inside it? Today, a place to keep track: HCP Packer, on the HashiCorp Cloud Platform.

The problem with lots of images

Every image gets an ID like A M I dash zero A B C, and so on. Long, random, and different in every region. Build in three regions, every week, and the spreadsheet starts to sweat. Worse, people copy those IDs into Terraform by hand. Sooner or later, someone pastes last month's. We need one place that knows what was built, when, where, and from what.

What HCP Packer records

HCP Packer is a registry. Each HCP project has one. Inside, a bucket holds one image family. Say, web base. Each run of packer build creates a version in that bucket. A version is an immutable record. A version has one build per builder in your template, for example one for AWS and one for Azure. And each build lists its artifacts. On AWS, that's an image ID for each region.

Metadata in the registry, images in the cloud

Here's the important bit. HCP Packer stores metadata about your images, not the images themselves. On the left, a Packer build, from a laptop or a CI pipeline, that's continuous integration. It builds an AMI, an Amazon Machine Image, in u s east one, and another in e u west two. The images stay in your AWS account, exactly where Packer made them. Meanwhile, Packer sends the metadata to the registry. The image IDs, the regions, when it was built, and the Git commit. To turn this on, you add an H C P packer registry block to the template, and give Packer HCP credentials. On the right, Terraform can now ask the registry for the right image ID, instead of anyone copying it. More on that in Part 7.

Turning it on

Connecting a build to the registry is a small change. Add an H C P packer registry block to the template. Give it a bucket name, a description, and labels if you like. Then give Packer credentials for your HCP project, usually through environment variables in CI. Now run packer build as usual. If the bucket doesn't exist yet, it's created, and the new version appears in it.

Ancestry

Images are often built on other images. A hardened base first, then a web image built on top of it. HCP Packer tracks that automatically. It records each artifact's source, its parent. So when the base image gets a newer version, the registry can warn you that the children are now out of date. Hold on to this family tree. It matters a lot in the revocation lesson.

Recap

Let's recap. HCP Packer is a registry of metadata. Your images stay in your cloud. A bucket holds versions, one per build run. Each version has builds, one per builder. Each build lists its artifacts, such as an image ID per region. And ancestry links every child image to the parent it came from.

Practice and what's next

That's the registry. No more spreadsheets of image IDs. Next lesson, Channels, where we give versions friendly names and promote them. See you there.

Gazeek Flash · free

Exam questions on your phone

Free questions on HCP Packer, the image registry: quick-fire batches and timed exams, on the web or Android.