Skip to content

Latest commit

 

History

History
73 lines (50 loc) · 3.3 KB

File metadata and controls

73 lines (50 loc) · 3.3 KB

Packer Basic Example

This folder contains a very simple Packer template to demonstrate how you can use Terratest to write automated tests for your Packer templates. The template just creates an up-to-date Ubuntu AMI by running apt-get update and apt-get upgrade.

Check out test/packer_basic_example_test.go to see how you can write automated tests for this simple template.

Note that this template doesn't do anything useful; it's just here to demonstrate the simplest usage pattern for Terratest. For slightly more complicated, real-world examples of Packer templates and the corresponding tests, see packer-docker-example and terraform-packer-example.

Building the Packer template manually

  1. Sign up for AWS.
  2. Configure your AWS credentials using one of the supported methods for AWS CLI tools, such as setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
  3. Install Packer and make sure it's on your PATH.
  4. Run packer build build.json.

Running automated tests against this Packer template

  1. Sign up for AWS.
  2. Configure your AWS credentials using one of the supported methods for AWS CLI tools, such as setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
  3. Install Packer and make sure it's on your PATH.
  4. Install Golang and make sure this code is checked out into your GOPATH.
  5. cd test
  6. dep ensure
  7. go test -v -run TestPackerBasicExample

Running automated tests against this Packer template for the GCP builder

  1. Sign up for GCP.
  2. Configure your GCP credentials using one of the Authentication methods.
  3. Install Packer and make sure it's on your PATH.
  4. Install Golang and make sure this code is checked out into your GOPATH.
  5. cd test
  6. dep ensure
  7. go test -v -run TestPackerGCPBasicExample

Running automated tests against this Packer template for the OCI builder

  1. Sign up for OCI.
  2. Configure your OCI credentials via CLI Configuration Information.
  3. Create VCN and subnet resources in your tenancy (a.k.a. a root compartment).
  4. (Optional) Create TF_VAR_pass_phrase environment property with the pass phrase for decrypting of the OCI API signing key (can be omitted if the key is not protected).
  5. Install Packer and make sure it's on your PATH.
  6. Install Golang and make sure this code is checked out into your GOPATH.
  7. cd test
  8. dep ensure
  9. go test -v -run TestPackerOciExample