Created
November 25, 2021 13:51
-
-
Save theherk/fd28a9f2b7270b556dde25bb67b89e09 to your computer and use it in GitHub Desktop.
Install the latest version of terraform locally with GNU Make.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OS := linux | |
ifeq (${shell uname},Darwin) | |
OS := darwin | |
endif | |
ARCH := amd64 | |
help: ## show help message | |
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z./_-]+:.*?##/ { printf " \033[36m%-16s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | |
bin: | |
mkdir -p $@ | |
bin/terraform: LATEST := ${shell curl --silent "https://api.github.com/repos/hashicorp/terraform/releases/latest" | jq ".. .tag_name? // empty" | tr -d '"v'} | |
bin/terraform: URL := https://releases.hashicorp.com/terraform/${LATEST}/terraform_${LATEST}_${OS}_${ARCH}.zip | |
bin/terraform: bin ## install terraform | |
curl -L ${URL} --output [email protected] | |
unzip -o [email protected] -d ${@D} | |
rm -f [email protected] | |
@echo 'export PATH=${@D}:$$PATH # remember to add to your PATH' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment