Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon

Adding Files to a Packer Build

Packer lets us create machine images for a variety of platforms through code. Part of this involves provisioning an initial machine to match our desired state. In this hands-on lab, we use both the `file` and `shell` provisioners to prepare a Packer template for a web instance.

Google Cloud Platform icon

Path Info

Clock icon Intermediate
Clock icon 15m
Clock icon Oct 02, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Add the File Provisioner(s)

    Please give the lab an extra three minutes before starting the lab activity. After that, log in to the provided Ubuntu Workstation server using the credentials provided.

    Note: There are multiple ways to complete this lab. We'll be using two file provisioner blocks objects. You could alternatively upload the entire files directory in one object and then move all files via script.

    Create an object to move the website files to /var/www/html/bookapp. Place it between the two shell provisioners.

    Add a second file object to move the Apache configuration to /tmp/. Since /etc/apache2 requires elevated privileges, we'll need to move the bookapp.conf file from /tmp/ via shell provisioner.

  2. Challenge

    Update the Scripts

    We'll need to update both the initial inline shell provisioner and the scripts provisioner that follows our file objects.

    Update the inline list to create the /var/www/html directory and grant ubuntu temporary ownership of it.

    Then, update the script itself to move our bookapp.conf Apache configuration.

  3. Challenge

    Test the Build

    Return to the packer.json file and update the variables for access key, secret key, and subnet ID. Save and exit, and then test the build.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans