Skip to content

hashicorp/se-demo-hcp-packer-essentials_assets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

HCP Packer Essentials - Assets

Create, manage and release machine images across multiple platforms.

Resources

Resource Description
Platform Instruqt
Demo Script HCP Packer Essentials - Demo Guide
Slides HCP Packer Essentials - Presentation
Recording HCP Packer Essentials - Recording
GitHub Assets HCP Packer Essentials - Instruqt Track
Contributors Joe Thompson, Gilberto Castillo

Innovation Lab: How to engage

  • New content requests: Field Request form (use the Asset request type)

  • On Slack: #proj-instruqt for Instruqt questions and issues

    • For access to HashiCorp Instruqt content, create an Instruqt account with your HashiCorp e-mail, then use the /instruqt_access integration in #proj-instruqt (see pinned messages for instructions)

    • Issues with upcoming/in-progress workshops/demos: tag @team-innovation-lab in #proj-instruqt (note that outside of US hours response may not be immediate at this time)


this

This repo contains a number of assets that for the demonstration.

.assets.api

The API folder provides a simple utility with URL shortcuts for API-driven operations for ease of reading, updating and controlling. The URL shortcuts are applicable to HCP Packer and Terraform Cloud.

For instance, the required ULR to create a channel in the HCP registry is as follows:

https://api.cloud.hashicorp.com/packer/2021-04-30/organizations/ac1ee2f1-42a7-4165-4efd-379187552e02/projects/4f204934-68cb-4165-43e7-abc91fb8987d

With a general operation implemented as follows:

curl -s -H "Authorization: Bearer *********" \
  -H "Content-Type: application/json" \
  -d '{"slug" : "hashicups-development", "incremental_version": 1}' \
  -X POST https://api.cloud.hashicorp.com/packer/2021-04-30/organizations/ac1ee2f1-42a7-4165-4efd-379187552e02/projects/4f204934-68cb-4165-43e7-abc91fb8987d/images/hashicups-frontend-ubuntu/channels

For ease of readability, update and future control, we express the operation with Bash shortcuts as follows:

# Our given identity during the set up stage
export HCP_ORGANIZATION_ID=ac1ee2f1-42a7-4165-4efd-379187552e02
export HCP_PROJECT_ID=4f204934-68cb-4165-43e7-abc91fb8987d

# This is generated dynamically
export HCP_CLIENT_TOKEN="*********"

# Specific to this exercise
export HCP_PACKER_BUCKET_SLUG="hashicups-frontend-ubuntu"
export HCP_PACKER_CHANNEL_SLUG="hashicups-development"

# Generic API endpoint for HCP Packer
export HCP_PACKER_BASE_URL=https://api.cloud.hashicorp.com/packer/2021-04-30/organizations/${HCP_ORGANIZATION_ID}/projects/${HCP_PROJECT_ID}

# URL Shortcut
export HCP_PACKER_API_CREATE_CHANNEL=${HCP_PACKER_BASE_URL}/images/${HCP_PACKER_BUCKET_SLUG}/channels

With the URL shortcuts, the operation, as implemented in the track, is easier to interpret and explain during a demonstration:

curl -s -H "Authorization: Bearer ${HCP_CLIENT_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"slug" : "'"${HCP_PACKER_CHANNEL_SLUG}"'", "incremental_version": 1}' \
  -X POST $HCP_PACKER_API_CREATE_CHANNEL

.assets.packer

The Packer folder contains the Packer templates that users modify during the demonstration.

Notable is the use of setup-deps-hashicups.sh to deploy the HashiCups application. The setup-deps-hashicups.sh is copied from learn-packer-multicloud courtesy of our Learn Team.

.assets.terraform

The Terraform folder contains deployment templates for Terraform. While the content is distributed across development and production, the same material is used in both exercises. However, during the first technical challenge in the demonstration, the user creates a local deployment under the development folder - which subsequently contains a Terraform state file.

.assets.watchdog

The watchdog folder contains a custom Python program to monitor arbitrary changes in a given directory. When changes are detected, the Python program launches a back-end script to do the following:

  1. Copy the Terraform production folder - simulating a branch fork
  2. Create a backend template for a workspace in Terraform Cloud
  3. Create a template for terraformrc
  4. Initialize Terraform - which creates the TFC workspace
  5. Upload required AWS and HCP credentials to the TFC workspace
  6. Get the HCP Packer runtask ID from the TFC org (if it exists)
  7. Attach the HCP Packer runtask to the TFC workspace (if it exists)
  8. Run remote terraform apply for the TFC workspace
  9. Tidy up and remove TFC sensitive data from this branch

.www

The www folder contains our custom Explainer Flask application. The application is intantiated in the demonstration as a production item. It's purpose is to provide an interactive visual guide during the demonstration. At the moment of writing this document, we are still exploring options with:

The motivation for this Explainer is to make use of the real estate available in the Instruqt Track during the demonstration. The material is identical to the slides in the HCP Packer Essentials - Presentation.