github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/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 18 ## Building the Packer template manually 19 20 1. Sign up for [AWS](https://aws.amazon.com/). 21 1. Configure your AWS credentials using one of the [supported methods for AWS CLI 22 tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html), such as setting the 23 `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. 24 1. Install [Packer](https://www.packer.io/) and make sure it's on your `PATH`. 25 1. Run `packer build build.json`. 26 27 28 29 30 ## Running automated tests against this Packer template 31 32 1. Sign up for [AWS](https://aws.amazon.com/). 33 1. Configure your AWS credentials using one of the [supported methods for AWS CLI 34 tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html), such as setting the 35 `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables. 36 1. Install [Packer](https://www.packer.io/) and make sure it's on your `PATH`. 37 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 38 1. `cd test` 39 1. `dep ensure` 40 1. `go test -v -run TestPackerBasicExample` 41 42 43 44 45 ## Running automated tests against this Packer template for the GCP builder 46 47 1. Sign up for [GCP](https://cloud.google.com/). 48 1. Configure your GCP credentials using one of the 49 [Authentication](https://www.packer.io/docs/builders/googlecompute.html#authentication) methods. 50 1. Install [Packer](https://www.packer.io/) and make sure it's on your `PATH`. 51 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 52 1. `cd test` 53 1. `dep ensure` 54 1. `go test -v -run TestPackerGCPBasicExample` 55 56 57 58 59 ## Running automated tests against this Packer template for the OCI builder 60 61 1. Sign up for [OCI](https://cloud.oracle.com/cloud-infrastructure). 62 1. Configure your OCI credentials via [CLI Configuration 63 Information](https://docs.cloud.oracle.com/iaas/Content/API/Concepts/sdkconfig.htm). 64 1. Create [VCN](https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/creatingnetwork.htm) and subnet 65 resources in your tenancy (a.k.a. a root compartment). 66 1. (Optional) Create `TF_VAR_pass_phrase` environment property with the pass phrase for decrypting of the OCI [API signing 67 key](https://docs.cloud.oracle.com/iaas/Content/API/Concepts/apisigningkey.htm) (can be omitted 68 if the key is not protected). 69 1. Install [Packer](https://www.packer.io/) and make sure it's on your `PATH`. 70 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 71 1. `cd test` 72 1. `dep ensure` 73 1. `go test -v -run TestPackerOciExample`