-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (65 loc) · 3.1 KB
/
Makefile
File metadata and controls
79 lines (65 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
TERRAFORM_VERSION ?= "1.4.4"
TERRAGRUNT_VERSION ?= "0.45.2"
UNAME := $(shell uname)
ARCH := $(shell uname -m)
SHELL := /bin/bash
ifeq ($(UNAME), Linux)
KERNAL := "linux"
endif
ifeq ($(UNAME), Darwin)
KERNAL := "darwin"
BREWLIST := $(shell brew list --formula)
endif
setup: tfenv-install-from-brew terraform-set-version terragrunt-install-from-source terraform-docs-install-from-brew
aws-vault-install-from-brew:
@echo "==> Installing aws-vault from brew..."
@if [[ ! "$(BREWLIST)" =~ "aws-vault" ]]; then brew install aws-vault; else echo "Already installed."; fi
@echo "==> Done."
tfenv-install-from-brew:
@echo "==> Installing tfenv from brew..."
@if [[ ! "$(BREWLIST)" =~ "tfenv" ]]; then brew install --build-from-source tfenv; else echo "Already installed."; fi
@echo "==> Done."
terraform-set-version:
@echo "Checking for tfenv..."
@if [[ ! "$(BREWLIST)" =~ "tfenv" ]]; then brew install --build-from-source tfenv; fi
@echo "==> Checking for terraform..."
@if [[ "$(shell tfenv list)" =~ "${TERRAFORM_VERSION}" ]]; then \
echo "Terraform v${TERRAFORM_VERSION} already installed. Switching version..."; \
tfenv use ${TERRAFORM_VERSION}; \
else \
echo "Current terraform v$(shell terraform --version) does not match v${TERRAFORM_VERSION}. Installing new version..."; \
tfenv install ${TERRAFORM_VERSION}; \
tfenv use ${TERRAFORM_VERSION}; \
fi
@echo "==> Done."
terraform-docs-install-from-brew:
@echo "==> Installing terraform-docs from brew..."
@if [[ ! "$(BREWLIST)" =~ "terraform-docs" ]]; then brew install --build-from-source terraform-docs; else echo "Already installed."; fi
@echo "==> Done."
terragrunt-install-from-source:
@echo "==> Installing Terragrunt from source..."
@if [ ! -f "/usr/local/bin/terragrunt" ]; then \
echo "==> Terragrunt binary not found"; \
make _terragrunt-install-from-source; \
else \
if [[ "$(shell terragrunt --version)" =~ "${TERRAGRUNT_VERSION}" ]]; then \
echo "==> Terragrunt v${TERRAGRUNT_VERSION} already installed. Nothing to do."; \
else \
echo "Current Terragrunt $(shell terragrunt --version) does not match v${TERRAGRUNT_VERSION}. Installing new version..."; \
make _terragrunt-install-from-source; \
fi \
fi
@echo "==> Done."
_terragrunt-install-from-source:
echo "==> https://github.com/gruntwork-io/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_${KERNAL}_${ARCH}"; \
curl -L https://github.com/gruntwork-io/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_${KERNAL}_${ARCH} --output /tmp/terragrunt; \
chmod +x /tmp/terragrunt; \
sudo mv /tmp/terragrunt /usr/local/bin; \
help:
@echo 'Makefile targets:'
@echo ' setup - Installs tfenv, Terraform and Terragrunt.'
@echo ' tfenv-install-from-brew - Installs tfenv for managing multiple Terraform versions.'
@echo ' terraform-set-version - Installs Terraform version if not already installed and sets the Terraform version using tfenv.'
@echo ' terragrunt-install-from-source - Installs Terragrunt from source.'
.PHONY: setup tfenv-install-from-brew terraform-set-version terragrunt-install-from-source
.PHONY: help