github.com/swisspost/terratest@v0.0.0-20230214120104-7ec6de2e1ae0/examples/packer-basic-example/README.md (about) 1 # Packer Basic Example 2 3 This folder contains a very simple Packer template to demonstrate how you can use Terratest to write automated tests 4 for your Packer templates. The template just creates an up-to-date Ubuntu AMI by running `apt-get update` and 5 `apt-get upgrade`. 6 7 Check out [test/packer_basic_example_test.go](/test/packer_basic_example_test.go) to see how you can write 8 automated tests for this simple template. 9 10 Note that this template doesn't do anything useful; it's just here to demonstrate the simplest usage pattern for 11 Terratest. For slightly more complicated, real-world examples of Packer templates and the corresponding tests, see 12 [packer-docker-example](/examples/packer-docker-example) and 13 [terraform-packer-example](/examples/terraform-packer-example). 14 15 16 17 ## Installation steps 18 1. Sign up for [AWS](https://aws.amazon.com/). 19 1. Configure your AWS credentials using one of the [supported methods for AWS CLI 20 tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html), such as setting the 21 `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. 22 1. Install [Packer](https://www.packer.io/) and make sure it's on your `PATH`. 23 24 ## Building the Packer template manually (Packer >= 1.7.0) 25 1. Run `packer init build.pkr.hcl`. # Use build-gcp.pkr.hcl if using GCP 26 1. Run `packer build build.pkr.hcl`. # Use build-gcp.pkr.hcl if using GCP 27 28 ## Building the Packer template manually (Packer < 1.7.0) 29 1. Run `packer build build.json`. 30 31 32 33 ## Running automated tests against this Packer template 34 35 1. Sign up for [AWS](https://aws.amazon.com/). 36 1. Configure your AWS credentials using one of the [supported methods for AWS CLI 37 tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html), such as setting the 38 `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. 39 1. Install [Packer](https://www.packer.io/) and make sure it's on your `PATH`. 40 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 41 1. `cd test` 42 1. `dep ensure` 43 1. `go test -v -run TestPackerBasicExample` 44 45 46 47 48 ## Running automated tests against this Packer template for the GCP builder 49 50 1. Sign up for [GCP](https://cloud.google.com/). 51 1. Configure your GCP credentials using one of the 52 [Authentication](https://www.packer.io/docs/builders/googlecompute.html#authentication) methods. 53 1. Install [Packer](https://www.packer.io/) and make sure it's on your `PATH`. 54 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 55 1. `cd test` 56 1. `dep ensure` 57 1. `go test -v -run TestPackerGCPBasicExample` 58 59 60 61 62 ## Running automated tests against this Packer template for the OCI builder 63 64 1. Sign up for [OCI](https://cloud.oracle.com/cloud-infrastructure). 65 1. Configure your OCI credentials via [CLI Configuration 66 Information](https://docs.cloud.oracle.com/iaas/Content/API/Concepts/sdkconfig.htm). 67 1. Create [VCN](https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/creatingnetwork.htm) and subnet 68 resources in your tenancy (a.k.a. a root compartment). 69 1. (Optional) Create `TF_VAR_pass_phrase` environment property with the pass phrase for decrypting of the OCI [API signing 70 key](https://docs.cloud.oracle.com/iaas/Content/API/Concepts/apisigningkey.htm) (can be omitted 71 if the key is not protected). 72 1. Install [Packer](https://www.packer.io/) and make sure it's on your `PATH`. 73 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 74 1. `cd test` 75 1. `dep ensure` 76 1. `go test -v -run TestPackerOciExample`