Skip to content

Commit

Permalink
Merge pull request #9 from mvisonneau/tmake
Browse files Browse the repository at this point in the history
Added an alias for accessing makefile from anywhere
  • Loading branch information
paulRbr authored Oct 20, 2017
2 parents 2fa1ab4 + 6eced6a commit 8d71ee2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
FROM hashicorp/terraform:0.10.7

RUN apk add --update make bash
RUN \
apk add --no-cache make bash ;\
echo 'alias tf-make="make -f /opt/terraform/Makefile"' >> ~/.bashrc

WORKDIR /opt/terraform
COPY . .
COPY . .

VOLUME [ /opt/terraform/providers ]
VOLUME [ /opt/terraform/modules ]
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
# https://github.com/paulRbr/terraform-makefile/pull/new/master
# Thanks! - Paul(rbr)

##
# MAKEFILE CONFIG
##
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))

##
# TERRAFORM INSTALL
##
Expand Down Expand Up @@ -50,43 +55,43 @@ ifeq ($(install),"true")
@unzip -d /usr/bin /usr/bin/terraform.zip && rm /usr/bin/terraform.zip
endif
@terraform --version
@bash terraform.sh init
@bash $(dir $(mkfile_path))/terraform.sh init

.PHONY: lint
lint: ## make lint # Rewrites config to canonical format
@terraform fmt -diff=true -check $(opts)

.PHONY: validate
validate: ## make validate # Basic syntax check
@bash terraform.sh validate $(opts)
@bash $(dir $(mkfile_path))/terraform.sh validate $(opts)

.PHONY: list
list: ## make list # List infra resources
@bash terraform.sh show $(opts)
@bash $(dir $(mkfile_path))/terraform.sh show $(opts)

.PHONY: refresh
refresh: ## make refresh # Refresh infra resources
@bash terraform.sh refresh $(opts)
@bash $(dir $(mkfile_path))/terraform.sh refresh $(opts)

.PHONY: console
console: ## make console # Console infra resources
@bash terraform.sh console $(opts)
@bash $(dir $(mkfile_path))/terraform.sh console $(opts)

.PHONY: import
import: ## make import # Import infra resources
bash terraform.sh import $(addr) $(value) $(opts)
bash $(dir $(mkfile_path))/terraform.sh import $(addr) $(value) $(opts)

.PHONY: dry-run
dry-run: ## make dry-run # Dry run resources changes
@bash terraform.sh plan $(opts)
@bash $(dir $(mkfile_path))/terraform.sh plan $(opts)

.PHONY: run
run: ## make run # Execute resources changes
@bash terraform.sh apply $(opts)
@bash $(dir $(mkfile_path))/terraform.sh apply $(opts)

.PHONY: destroy
destroy: ## make destroy # Destroy resources
@bash terraform.sh destroy $(opts)
@bash $(dir $(mkfile_path))/terraform.sh destroy $(opts)

help:
@printf "\033[32mTerraform-makefile v$(version)\033[0m\n"
Expand Down

0 comments on commit 8d71ee2

Please sign in to comment.