Repository: chanzuckerberg/fogg
Pull request #747 (2022-10-04 21:06:37)

feat: Add terraform validate support
### Summary
A description of changes or issues addressed by this PR. Provide links to relevant PRs if any.

### Test Plan
Say unittests, or list out steps to verify changes.

### References
(Optional) Additional links to provide more context.



Patch:
diff --git a/templates/templates/repo/scripts/component.mk b/templates/templates/repo/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/templates/templates/repo/scripts/component.mk
+++ b/templates/templates/repo/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/templates/templates/repo/scripts/module.mk b/templates/templates/repo/scripts/module.mk
index 3de23397..03476352 100644
--- a/templates/templates/repo/scripts/module.mk
+++ b/templates/templates/repo/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 


Test patch:
diff --git a/testdata/auth0_provider_yaml/scripts/component.mk b/testdata/auth0_provider_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/auth0_provider_yaml/scripts/component.mk
+++ b/testdata/auth0_provider_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/auth0_provider_yaml/scripts/module.mk b/testdata/auth0_provider_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/auth0_provider_yaml/scripts/module.mk
+++ b/testdata/auth0_provider_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/bless_provider_yaml/scripts/component.mk b/testdata/bless_provider_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/bless_provider_yaml/scripts/component.mk
+++ b/testdata/bless_provider_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/bless_provider_yaml/scripts/module.mk b/testdata/bless_provider_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/bless_provider_yaml/scripts/module.mk
+++ b/testdata/bless_provider_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/circleci/scripts/component.mk b/testdata/circleci/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/circleci/scripts/component.mk
+++ b/testdata/circleci/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/circleci/scripts/module.mk b/testdata/circleci/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/circleci/scripts/module.mk
+++ b/testdata/circleci/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/github_actions/scripts/component.mk b/testdata/github_actions/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/github_actions/scripts/component.mk
+++ b/testdata/github_actions/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/github_actions/scripts/module.mk b/testdata/github_actions/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/github_actions/scripts/module.mk
+++ b/testdata/github_actions/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/github_provider_yaml/scripts/component.mk b/testdata/github_provider_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/github_provider_yaml/scripts/component.mk
+++ b/testdata/github_provider_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/github_provider_yaml/scripts/module.mk b/testdata/github_provider_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/github_provider_yaml/scripts/module.mk
+++ b/testdata/github_provider_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/okta_provider_yaml/scripts/component.mk b/testdata/okta_provider_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/okta_provider_yaml/scripts/component.mk
+++ b/testdata/okta_provider_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/okta_provider_yaml/scripts/module.mk b/testdata/okta_provider_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/okta_provider_yaml/scripts/module.mk
+++ b/testdata/okta_provider_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/remote_backend_yaml/scripts/component.mk b/testdata/remote_backend_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/remote_backend_yaml/scripts/component.mk
+++ b/testdata/remote_backend_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/remote_backend_yaml/scripts/module.mk b/testdata/remote_backend_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/remote_backend_yaml/scripts/module.mk
+++ b/testdata/remote_backend_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/snowflake_provider_yaml/scripts/component.mk b/testdata/snowflake_provider_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/snowflake_provider_yaml/scripts/component.mk
+++ b/testdata/snowflake_provider_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/snowflake_provider_yaml/scripts/module.mk b/testdata/snowflake_provider_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/snowflake_provider_yaml/scripts/module.mk
+++ b/testdata/snowflake_provider_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/tfe_config/scripts/component.mk b/testdata/tfe_config/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/tfe_config/scripts/component.mk
+++ b/testdata/tfe_config/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/tfe_config/scripts/module.mk b/testdata/tfe_config/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/tfe_config/scripts/module.mk
+++ b/testdata/tfe_config/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/tfe_provider_yaml/scripts/component.mk b/testdata/tfe_provider_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/tfe_provider_yaml/scripts/component.mk
+++ b/testdata/tfe_provider_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/tfe_provider_yaml/scripts/module.mk b/testdata/tfe_provider_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/tfe_provider_yaml/scripts/module.mk
+++ b/testdata/tfe_provider_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/v2_full_yaml/scripts/component.mk b/testdata/v2_full_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/v2_full_yaml/scripts/component.mk
+++ b/testdata/v2_full_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/v2_full_yaml/scripts/module.mk b/testdata/v2_full_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/v2_full_yaml/scripts/module.mk
+++ b/testdata/v2_full_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/v2_minimal_valid_yaml/scripts/component.mk b/testdata/v2_minimal_valid_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/v2_minimal_valid_yaml/scripts/component.mk
+++ b/testdata/v2_minimal_valid_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/v2_minimal_valid_yaml/scripts/module.mk b/testdata/v2_minimal_valid_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/v2_minimal_valid_yaml/scripts/module.mk
+++ b/testdata/v2_minimal_valid_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check
 
diff --git a/testdata/v2_no_aws_provider_yaml/scripts/component.mk b/testdata/v2_no_aws_provider_yaml/scripts/component.mk
index 0caacd7f..0ac7e2ec 100644
--- a/testdata/v2_no_aws_provider_yaml/scripts/component.mk
+++ b/testdata/v2_no_aws_provider_yaml/scripts/component.mk
@@ -20,6 +20,10 @@ fmt: terraform ## format code in this component
 	$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## validate code in this component
+	$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 lint: lint-terraform-fmt lint-tflint ## run all linters for this component
 .PHONY: lint
 
diff --git a/testdata/v2_no_aws_provider_yaml/scripts/module.mk b/testdata/v2_no_aws_provider_yaml/scripts/module.mk
index 3de23397..03476352 100644
--- a/testdata/v2_no_aws_provider_yaml/scripts/module.mk
+++ b/testdata/v2_no_aws_provider_yaml/scripts/module.mk
@@ -12,6 +12,10 @@ fmt: terraform ## run terraform fmt on this module
 	@$(terraform_command) fmt $(TF_ARGS)
 .PHONY: fmt
 
+validate: terraform ## run terraform validate on this module
+	@$(terraform_command) validate $(TF_ARGS)
+.PHONY: validate
+
 check: lint check-docs ## run all checks on this module
 .PHONY: check