Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] atlantis autoplan when modules change #304

Merged
merged 7 commits into from
Jun 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions templates/atlantis/atlantis.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ projects:
- name: {{ $project.Name }}
dir: {{ $project.Dir }}
workflow: fogg
autoplan:
when_modified: ["{{ .PathToRepoRoot }}terraform/modules/*/*.tf", "*.tf*"]
enabled: true
{{ end }}

workflows:
Expand Down
1 change: 1 addition & 0 deletions templates/repo/scripts/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MODE ?= local

ifeq ($(MODE),atlantis)
export AWS_CONFIG_FILE=$(REPO_ROOT)/config/atlantis-aws-config
TF_ARGS ?= -no-color
endif


Expand Down
18 changes: 9 additions & 9 deletions templates/repo/scripts/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ check: lint check-plan

fmt: terraform
@printf "fmt: ";
@for f in $(TF); do printf .; $(terraform_command) fmt $$f; done
@for f in $(TF); do printf .; $(terraform_command) fmt $(TF_ARGS) $$f; done
@echo
.PHONY: fmt

Expand All @@ -34,24 +34,24 @@ endif
.PHONY: lint-tflint

terraform-validate: terraform init
@$(terraform_command) validate -check-variables=true
@$(terraform_command) validate $(TF_ARGS) -check-variables=true
.PHONY: terraform-validate

lint-terraform-fmt: terraform
@printf "fmt check: "
@for f in $(TF); do \
printf . \
$(terraform_command) fmt --check=true --diff=true $$f || exit $$? ; \
$(terraform_command) fmt $(TF_ARGS) --check=true --diff=true $$f || exit $$? ; \
done
@echo
.PHONY: lint-terraform-fmt

ifeq ($(MODE),local)
plan: init fmt
@$(terraform_command) plan
@$(terraform_command) plan $(TF_ARGS) -input=false
else ifeq ($(MODE),atlantis)
plan: init lint
@$(terraform_command) plan -input=false -no-color -out $(PLANFILE) | scenery
@$(terraform_command) plan $(TF_ARGS) -input=false -out $(PLANFILE) | scenery
else
@echo "Unknown MODE: $(MODE)"
@exit -1
Expand All @@ -66,10 +66,10 @@ ifneq ($(FORCE),1)
exit -1
endif
endif
@$(terraform_command) apply -auto-approve=$(AUTO_APPROVE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=$(AUTO_APPROVE)
else ifeq ($(MODE),atlantis)
apply:
@$(terraform_command) apply -auto-approve=true $(PLANFILE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=true $(PLANFILE)
else
echo "Unknown mode: $(MODE)"
exit -1
Expand All @@ -92,15 +92,15 @@ init: terraform
ifeq ($(MODE),local)
@$(terraform_command) init -input=false
else ifeq ($(MODE),atlantis)
@$(terraform_command) init -input=false -no-color
@$(terraform_command) init $(TF_ARGS) -input=false
else
@echo "Unknown MODE: $(MODE)"
@exit -1
endif
.PHONY: init

check-plan: init
@$(terraform_command) plan -detailed-exitcode; \
@$(terraform_command) plan $(TF_ARGS) -detailed-exitcode; \
ERR=$$?; \
if [ $$ERR -eq 0 ] ; then \
echo "Success"; \
Expand Down
1 change: 1 addition & 0 deletions testdata/bless_provider/scripts/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MODE ?= local

ifeq ($(MODE),atlantis)
export AWS_CONFIG_FILE=$(REPO_ROOT)/config/atlantis-aws-config
TF_ARGS ?= -no-color
endif


Expand Down
18 changes: 9 additions & 9 deletions testdata/bless_provider/scripts/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ check: lint check-plan

fmt: terraform
@printf "fmt: ";
@for f in $(TF); do printf .; $(terraform_command) fmt $$f; done
@for f in $(TF); do printf .; $(terraform_command) fmt $(TF_ARGS) $$f; done
@echo
.PHONY: fmt

Expand All @@ -34,24 +34,24 @@ endif
.PHONY: lint-tflint

terraform-validate: terraform init
@$(terraform_command) validate -check-variables=true
@$(terraform_command) validate $(TF_ARGS) -check-variables=true
.PHONY: terraform-validate

lint-terraform-fmt: terraform
@printf "fmt check: "
@for f in $(TF); do \
printf . \
$(terraform_command) fmt --check=true --diff=true $$f || exit $$? ; \
$(terraform_command) fmt $(TF_ARGS) --check=true --diff=true $$f || exit $$? ; \
done
@echo
.PHONY: lint-terraform-fmt

ifeq ($(MODE),local)
plan: init fmt
@$(terraform_command) plan
@$(terraform_command) plan $(TF_ARGS) -input=false
else ifeq ($(MODE),atlantis)
plan: init lint
@$(terraform_command) plan -input=false -no-color -out $(PLANFILE) | scenery
@$(terraform_command) plan $(TF_ARGS) -input=false -out $(PLANFILE) | scenery
else
@echo "Unknown MODE: $(MODE)"
@exit -1
Expand All @@ -66,10 +66,10 @@ ifneq ($(FORCE),1)
exit -1
endif
endif
@$(terraform_command) apply -auto-approve=$(AUTO_APPROVE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=$(AUTO_APPROVE)
else ifeq ($(MODE),atlantis)
apply:
@$(terraform_command) apply -auto-approve=true $(PLANFILE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=true $(PLANFILE)
else
echo "Unknown mode: $(MODE)"
exit -1
Expand All @@ -92,15 +92,15 @@ init: terraform
ifeq ($(MODE),local)
@$(terraform_command) init -input=false
else ifeq ($(MODE),atlantis)
@$(terraform_command) init -input=false -no-color
@$(terraform_command) init $(TF_ARGS) -input=false
else
@echo "Unknown MODE: $(MODE)"
@exit -1
endif
.PHONY: init

check-plan: init
@$(terraform_command) plan -detailed-exitcode; \
@$(terraform_command) plan $(TF_ARGS) -detailed-exitcode; \
ERR=$$?; \
if [ $$ERR -eq 0 ] ; then \
echo "Success"; \
Expand Down
1 change: 1 addition & 0 deletions testdata/okta_provider/scripts/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MODE ?= local

ifeq ($(MODE),atlantis)
export AWS_CONFIG_FILE=$(REPO_ROOT)/config/atlantis-aws-config
TF_ARGS ?= -no-color
endif


Expand Down
18 changes: 9 additions & 9 deletions testdata/okta_provider/scripts/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ check: lint check-plan

fmt: terraform
@printf "fmt: ";
@for f in $(TF); do printf .; $(terraform_command) fmt $$f; done
@for f in $(TF); do printf .; $(terraform_command) fmt $(TF_ARGS) $$f; done
@echo
.PHONY: fmt

Expand All @@ -34,24 +34,24 @@ endif
.PHONY: lint-tflint

terraform-validate: terraform init
@$(terraform_command) validate -check-variables=true
@$(terraform_command) validate $(TF_ARGS) -check-variables=true
.PHONY: terraform-validate

lint-terraform-fmt: terraform
@printf "fmt check: "
@for f in $(TF); do \
printf . \
$(terraform_command) fmt --check=true --diff=true $$f || exit $$? ; \
$(terraform_command) fmt $(TF_ARGS) --check=true --diff=true $$f || exit $$? ; \
done
@echo
.PHONY: lint-terraform-fmt

ifeq ($(MODE),local)
plan: init fmt
@$(terraform_command) plan
@$(terraform_command) plan $(TF_ARGS) -input=false
else ifeq ($(MODE),atlantis)
plan: init lint
@$(terraform_command) plan -input=false -no-color -out $(PLANFILE) | scenery
@$(terraform_command) plan $(TF_ARGS) -input=false -out $(PLANFILE) | scenery
else
@echo "Unknown MODE: $(MODE)"
@exit -1
Expand All @@ -66,10 +66,10 @@ ifneq ($(FORCE),1)
exit -1
endif
endif
@$(terraform_command) apply -auto-approve=$(AUTO_APPROVE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=$(AUTO_APPROVE)
else ifeq ($(MODE),atlantis)
apply:
@$(terraform_command) apply -auto-approve=true $(PLANFILE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=true $(PLANFILE)
else
echo "Unknown mode: $(MODE)"
exit -1
Expand All @@ -92,15 +92,15 @@ init: terraform
ifeq ($(MODE),local)
@$(terraform_command) init -input=false
else ifeq ($(MODE),atlantis)
@$(terraform_command) init -input=false -no-color
@$(terraform_command) init $(TF_ARGS) -input=false
else
@echo "Unknown MODE: $(MODE)"
@exit -1
endif
.PHONY: init

check-plan: init
@$(terraform_command) plan -detailed-exitcode; \
@$(terraform_command) plan $(TF_ARGS) -detailed-exitcode; \
ERR=$$?; \
if [ $$ERR -eq 0 ] ; then \
echo "Success"; \
Expand Down
1 change: 1 addition & 0 deletions testdata/snowflake_provider/scripts/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MODE ?= local

ifeq ($(MODE),atlantis)
export AWS_CONFIG_FILE=$(REPO_ROOT)/config/atlantis-aws-config
TF_ARGS ?= -no-color
endif


Expand Down
18 changes: 9 additions & 9 deletions testdata/snowflake_provider/scripts/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ check: lint check-plan

fmt: terraform
@printf "fmt: ";
@for f in $(TF); do printf .; $(terraform_command) fmt $$f; done
@for f in $(TF); do printf .; $(terraform_command) fmt $(TF_ARGS) $$f; done
@echo
.PHONY: fmt

Expand All @@ -34,24 +34,24 @@ endif
.PHONY: lint-tflint

terraform-validate: terraform init
@$(terraform_command) validate -check-variables=true
@$(terraform_command) validate $(TF_ARGS) -check-variables=true
.PHONY: terraform-validate

lint-terraform-fmt: terraform
@printf "fmt check: "
@for f in $(TF); do \
printf . \
$(terraform_command) fmt --check=true --diff=true $$f || exit $$? ; \
$(terraform_command) fmt $(TF_ARGS) --check=true --diff=true $$f || exit $$? ; \
done
@echo
.PHONY: lint-terraform-fmt

ifeq ($(MODE),local)
plan: init fmt
@$(terraform_command) plan
@$(terraform_command) plan $(TF_ARGS) -input=false
else ifeq ($(MODE),atlantis)
plan: init lint
@$(terraform_command) plan -input=false -no-color -out $(PLANFILE) | scenery
@$(terraform_command) plan $(TF_ARGS) -input=false -out $(PLANFILE) | scenery
else
@echo "Unknown MODE: $(MODE)"
@exit -1
Expand All @@ -66,10 +66,10 @@ ifneq ($(FORCE),1)
exit -1
endif
endif
@$(terraform_command) apply -auto-approve=$(AUTO_APPROVE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=$(AUTO_APPROVE)
else ifeq ($(MODE),atlantis)
apply:
@$(terraform_command) apply -auto-approve=true $(PLANFILE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=true $(PLANFILE)
else
echo "Unknown mode: $(MODE)"
exit -1
Expand All @@ -92,15 +92,15 @@ init: terraform
ifeq ($(MODE),local)
@$(terraform_command) init -input=false
else ifeq ($(MODE),atlantis)
@$(terraform_command) init -input=false -no-color
@$(terraform_command) init $(TF_ARGS) -input=false
else
@echo "Unknown MODE: $(MODE)"
@exit -1
endif
.PHONY: init

check-plan: init
@$(terraform_command) plan -detailed-exitcode; \
@$(terraform_command) plan $(TF_ARGS) -detailed-exitcode; \
ERR=$$?; \
if [ $$ERR -eq 0 ] ; then \
echo "Success"; \
Expand Down
1 change: 1 addition & 0 deletions testdata/v1_full/scripts/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MODE ?= local

ifeq ($(MODE),atlantis)
export AWS_CONFIG_FILE=$(REPO_ROOT)/config/atlantis-aws-config
TF_ARGS ?= -no-color
endif


Expand Down
18 changes: 9 additions & 9 deletions testdata/v1_full/scripts/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ check: lint check-plan

fmt: terraform
@printf "fmt: ";
@for f in $(TF); do printf .; $(terraform_command) fmt $$f; done
@for f in $(TF); do printf .; $(terraform_command) fmt $(TF_ARGS) $$f; done
@echo
.PHONY: fmt

Expand All @@ -34,24 +34,24 @@ endif
.PHONY: lint-tflint

terraform-validate: terraform init
@$(terraform_command) validate -check-variables=true
@$(terraform_command) validate $(TF_ARGS) -check-variables=true
.PHONY: terraform-validate

lint-terraform-fmt: terraform
@printf "fmt check: "
@for f in $(TF); do \
printf . \
$(terraform_command) fmt --check=true --diff=true $$f || exit $$? ; \
$(terraform_command) fmt $(TF_ARGS) --check=true --diff=true $$f || exit $$? ; \
done
@echo
.PHONY: lint-terraform-fmt

ifeq ($(MODE),local)
plan: init fmt
@$(terraform_command) plan
@$(terraform_command) plan $(TF_ARGS) -input=false
else ifeq ($(MODE),atlantis)
plan: init lint
@$(terraform_command) plan -input=false -no-color -out $(PLANFILE) | scenery
@$(terraform_command) plan $(TF_ARGS) -input=false -out $(PLANFILE) | scenery
else
@echo "Unknown MODE: $(MODE)"
@exit -1
Expand All @@ -66,10 +66,10 @@ ifneq ($(FORCE),1)
exit -1
endif
endif
@$(terraform_command) apply -auto-approve=$(AUTO_APPROVE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=$(AUTO_APPROVE)
else ifeq ($(MODE),atlantis)
apply:
@$(terraform_command) apply -auto-approve=true $(PLANFILE)
@$(terraform_command) apply $(TF_ARGS) -auto-approve=true $(PLANFILE)
else
echo "Unknown mode: $(MODE)"
exit -1
Expand All @@ -92,15 +92,15 @@ init: terraform
ifeq ($(MODE),local)
@$(terraform_command) init -input=false
else ifeq ($(MODE),atlantis)
@$(terraform_command) init -input=false -no-color
@$(terraform_command) init $(TF_ARGS) -input=false
else
@echo "Unknown MODE: $(MODE)"
@exit -1
endif
.PHONY: init

check-plan: init
@$(terraform_command) plan -detailed-exitcode; \
@$(terraform_command) plan $(TF_ARGS) -detailed-exitcode; \
ERR=$$?; \
if [ $$ERR -eq 0 ] ; then \
echo "Success"; \
Expand Down
Loading