-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
39 lines (35 loc) · 1.08 KB
/
Makefile
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
MODULES ?= $(shell find * -type d | grep -v '/\.' | grep -v 'modules')
ROOT ?= $(shell pwd)
default: lint
lint:
@terraform fmt -check -diff
@for module in $(MODULES); do \
if ls $$module/*tf 1> /dev/null 2>&1; then \
cd $$module; \
echo "Checking $$module"; \
terraform init; \
terraform validate 1> /dev/null || exit 1; \
cd $(ROOT); \
fi; \
done
new:
@if [ -z "$(NAME)" ]; then \
echo "Usage: make new NAME=name"; \
exit 1; \
fi
@mkdir $(NAME)
@cp .terraform-version $(NAME)
@echo 'terraform {' >> $(NAME)/main.tf
@echo ' backend "s3" {' >> $(NAME)/main.tf
@echo ' bucket = "terraform.pokedextracker.com"' >> $(NAME)/main.tf
@echo ' encrypt = true' >> $(NAME)/main.tf
@echo ' key = "$(NAME).tfstate"' >> $(NAME)/main.tf
@echo ' region = "us-west-2"' >> $(NAME)/main.tf
@echo ' }' >> $(NAME)/main.tf
@echo '}' >> $(NAME)/main.tf
@echo '' >> $(NAME)/main.tf
@echo 'provider "aws" {' >> $(NAME)/main.tf
@echo ' region = "us-west-2"' >> $(NAME)/main.tf
@echo '}' >> $(NAME)/main.tf
@touch $(NAME)/outputs.tf
.PHONY: lint