open-nomad/e2e/terraform/packer/build
Mahmood Ali 0853d48927
e2e: Spin clusters with custom url binaries (#10656)
Ease spinning up a cluster, where binaries are fetched from arbitrary
urls.  These could be CircleCI `build-binaries` job artifacts, or
presigned S3 urls.

Co-authored-by: Tim Gross <tgross@hashicorp.com>
2021-05-25 13:47:39 -04:00

37 lines
572 B
Bash
Executable file

#!/usr/bin/env bash
set -u
set -e
usage() {
cat <<EOF
Usage: build <target>
Build an AMI for the target configuration
Examples
build ubuntu-bionic-amd64
EOF
exit 2
}
if [[ $# -ne 1 ]]; then
usage
fi
target="${1/%.pkr.hcl/}"
directory="$(dirname "$0")"
cd "${directory}"
if ! test -f "${target}.pkr.hcl"; then
echo "${target}.pkr.hcl is not present" >&2
exit 1
fi
sha=$(git log -n 1 --pretty=format:%H "${directory}")
echo packer build --var "build_sha=${sha}" "${target}.pkr.hcl"
packer build --var "build_sha=${sha}" "${target}.pkr.hcl"