Repository: chanzuckerberg/fogg
Pull request #309 (2019-06-26 14:57:56)

[feature] Move terraform validate from lint stage to plan stage
### Summary
Having `terraform validate` as a substep of `lint` forces us to have fully configured providers (including credentials/secrets). I would like to be able to lint code without requiring these secrets be present. One way could be moving this validation over to the plan stage (although this feels somewhat redundant).  

### Test Plan

### References


Patch:
diff --git a/templates/repo/scripts/component.mk b/templates/repo/scripts/component.mk
index b13842c1..b06305e0 100644
--- a/templates/repo/scripts/component.mk
+++ b/templates/repo/scripts/component.mk
@@ -21,7 +21,7 @@ fmt: terraform
 	@echo
 .PHONY: fmt
 
-lint: terraform-validate lint-terraform-fmt lint-tflint
+lint: lint-terraform-fmt lint-tflint
 .PHONY: lint
 
 lint-tflint: init
@@ -33,10 +33,6 @@ else
 endif
 .PHONY: lint-tflint
 
-terraform-validate: terraform init
-	@$(terraform_command) validate $(TF_ARGS) -check-variables=true
-.PHONY: terraform-validate
-
 lint-terraform-fmt: terraform
 	@printf "fmt check: "
 	@for f in $(TF); do \


Test patch:
diff --git a/testdata/bless_provider/scripts/component.mk b/testdata/bless_provider/scripts/component.mk
index b13842c1..b06305e0 100644
--- a/testdata/bless_provider/scripts/component.mk
+++ b/testdata/bless_provider/scripts/component.mk
@@ -21,7 +21,7 @@ fmt: terraform
 	@echo
 .PHONY: fmt
 
-lint: terraform-validate lint-terraform-fmt lint-tflint
+lint: lint-terraform-fmt lint-tflint
 .PHONY: lint
 
 lint-tflint: init
@@ -33,10 +33,6 @@ else
 endif
 .PHONY: lint-tflint
 
-terraform-validate: terraform init
-	@$(terraform_command) validate $(TF_ARGS) -check-variables=true
-.PHONY: terraform-validate
-
 lint-terraform-fmt: terraform
 	@printf "fmt check: "
 	@for f in $(TF); do \
diff --git a/testdata/okta_provider/scripts/component.mk b/testdata/okta_provider/scripts/component.mk
index b13842c1..b06305e0 100644
--- a/testdata/okta_provider/scripts/component.mk
+++ b/testdata/okta_provider/scripts/component.mk
@@ -21,7 +21,7 @@ fmt: terraform
 	@echo
 .PHONY: fmt
 
-lint: terraform-validate lint-terraform-fmt lint-tflint
+lint: lint-terraform-fmt lint-tflint
 .PHONY: lint
 
 lint-tflint: init
@@ -33,10 +33,6 @@ else
 endif
 .PHONY: lint-tflint
 
-terraform-validate: terraform init
-	@$(terraform_command) validate $(TF_ARGS) -check-variables=true
-.PHONY: terraform-validate
-
 lint-terraform-fmt: terraform
 	@printf "fmt check: "
 	@for f in $(TF); do \
diff --git a/testdata/snowflake_provider/scripts/component.mk b/testdata/snowflake_provider/scripts/component.mk
index b13842c1..b06305e0 100644
--- a/testdata/snowflake_provider/scripts/component.mk
+++ b/testdata/snowflake_provider/scripts/component.mk
@@ -21,7 +21,7 @@ fmt: terraform
 	@echo
 .PHONY: fmt
 
-lint: terraform-validate lint-terraform-fmt lint-tflint
+lint: lint-terraform-fmt lint-tflint
 .PHONY: lint
 
 lint-tflint: init
@@ -33,10 +33,6 @@ else
 endif
 .PHONY: lint-tflint
 
-terraform-validate: terraform init
-	@$(terraform_command) validate $(TF_ARGS) -check-variables=true
-.PHONY: terraform-validate
-
 lint-terraform-fmt: terraform
 	@printf "fmt check: "
 	@for f in $(TF); do \
diff --git a/testdata/v1_full/scripts/component.mk b/testdata/v1_full/scripts/component.mk
index b13842c1..b06305e0 100644
--- a/testdata/v1_full/scripts/component.mk
+++ b/testdata/v1_full/scripts/component.mk
@@ -21,7 +21,7 @@ fmt: terraform
 	@echo
 .PHONY: fmt
 
-lint: terraform-validate lint-terraform-fmt lint-tflint
+lint: lint-terraform-fmt lint-tflint
 .PHONY: lint
 
 lint-tflint: init
@@ -33,10 +33,6 @@ else
 endif
 .PHONY: lint-tflint
 
-terraform-validate: terraform init
-	@$(terraform_command) validate $(TF_ARGS) -check-variables=true
-.PHONY: terraform-validate
-
 lint-terraform-fmt: terraform
 	@printf "fmt check: "
 	@for f in $(TF); do \
diff --git a/testdata/v2_full/scripts/component.mk b/testdata/v2_full/scripts/component.mk
index b13842c1..b06305e0 100644
--- a/testdata/v2_full/scripts/component.mk
+++ b/testdata/v2_full/scripts/component.mk
@@ -21,7 +21,7 @@ fmt: terraform
 	@echo
 .PHONY: fmt
 
-lint: terraform-validate lint-terraform-fmt lint-tflint
+lint: lint-terraform-fmt lint-tflint
 .PHONY: lint
 
 lint-tflint: init
@@ -33,10 +33,6 @@ else
 endif
 .PHONY: lint-tflint
 
-terraform-validate: terraform init
-	@$(terraform_command) validate $(TF_ARGS) -check-variables=true
-.PHONY: terraform-validate
-
 lint-terraform-fmt: terraform
 	@printf "fmt check: "
 	@for f in $(TF); do \
diff --git a/testdata/v2_minimal_valid/scripts/component.mk b/testdata/v2_minimal_valid/scripts/component.mk
index b13842c1..b06305e0 100644
--- a/testdata/v2_minimal_valid/scripts/component.mk
+++ b/testdata/v2_minimal_valid/scripts/component.mk
@@ -21,7 +21,7 @@ fmt: terraform
 	@echo
 .PHONY: fmt
 
-lint: terraform-validate lint-terraform-fmt lint-tflint
+lint: lint-terraform-fmt lint-tflint
 .PHONY: lint
 
 lint-tflint: init
@@ -33,10 +33,6 @@ else
 endif
 .PHONY: lint-tflint
 
-terraform-validate: terraform init
-	@$(terraform_command) validate $(TF_ARGS) -check-variables=true
-.PHONY: terraform-validate
-
 lint-terraform-fmt: terraform
 	@printf "fmt check: "
 	@for f in $(TF); do \
diff --git a/testdata/v2_no_aws_provider/scripts/component.mk b/testdata/v2_no_aws_provider/scripts/component.mk
index b13842c1..b06305e0 100644
--- a/testdata/v2_no_aws_provider/scripts/component.mk
+++ b/testdata/v2_no_aws_provider/scripts/component.mk
@@ -21,7 +21,7 @@ fmt: terraform
 	@echo
 .PHONY: fmt
 
-lint: terraform-validate lint-terraform-fmt lint-tflint
+lint: lint-terraform-fmt lint-tflint
 .PHONY: lint
 
 lint-tflint: init
@@ -33,10 +33,6 @@ else
 endif
 .PHONY: lint-tflint
 
-terraform-validate: terraform init
-	@$(terraform_command) validate $(TF_ARGS) -check-variables=true
-.PHONY: terraform-validate
-
 lint-terraform-fmt: terraform
 	@printf "fmt check: "
 	@for f in $(TF); do \