|
| 1 | +# This file is for you! Edit it to implement your own Terraform make targets. |
| 2 | + |
| 3 | +# ============================================================================== |
| 4 | +# Custom implementation - implementation of a make target should not exceed 5 lines of effective code. |
| 5 | +# In most cases there should be no need to modify the existing make targets. |
| 6 | + |
| 7 | +terraform-fmt: # Format Terraform files - optional: terraform_dir|dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is one of the module variables or the example directory, if not set], terraform_opts|opts=[options to pass to the Terraform fmt command, default is '-recursive'] @Quality |
| 8 | + make _terraform cmd="fmt" \ |
| 9 | + dir=$(or ${terraform_dir}, ${dir}) \ |
| 10 | + opts=$(or ${terraform_opts}, ${opts}) |
| 11 | + |
| 12 | +_terraform: # Terraform command wrapper - mandatory: cmd=[command to execute]; optional: dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is one of the module variables or the example directory, if not set], opts=[options to pass to the Terraform command, default is none/empty] |
| 13 | + # 'TERRAFORM_STACK' is passed to the functions as environment variable |
| 14 | + TERRAFORM_STACK=$(or ${TERRAFORM_STACK}, $(or ${terraform_stack}, $(or ${STACK}, ${stack}))) |
| 15 | + dir=$(or ${dir}, ${TERRAFORM_STACK}) |
| 16 | + . "scripts/terraform/terraform.lib.sh"; \ |
| 17 | + terraform-${cmd} # 'dir' and 'opts' are accessible by the function as environment variables, if set |
| 18 | + |
| 19 | +# ============================================================================== |
| 20 | +# Quality checks - please DO NOT edit this section! |
| 21 | + |
| 22 | +terraform-shellscript-lint: # Lint all Terraform module shell scripts @Quality |
| 23 | + for file in $$(find scripts/terraform -type f -name "*.sh"); do |
| 24 | + file=$${file} scripts/shellscript-linter.sh |
| 25 | + done |
| 26 | + |
| 27 | +terraform-sec: # TFSEC check against Terraform files - optional: terraform_dir|dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is one of the module variables or the example directory, if not set], terraform_opts|opts=[options to pass to the Terraform fmt command, default is '-recursive'] @Quality |
| 28 | + tfsec infrastructure/terraform \ |
| 29 | + --force-all-dirs \ |
| 30 | + --exclude-downloaded-modules \ |
| 31 | + --config-file scripts/config/tfsec.yml |
| 32 | + |
| 33 | +# ============================================================================== |
| 34 | +# Configuration - please DO NOT edit this section! |
| 35 | + |
| 36 | +terraform-install: # Install Terraform @Installation |
| 37 | + make _install-dependency name="terraform" |
| 38 | + |
| 39 | +# ============================================================================== |
| 40 | + |
| 41 | +${VERBOSE}.SILENT: \ |
| 42 | + _terraform \ |
| 43 | + clean \ |
| 44 | + terraform-apply \ |
| 45 | + terraform-destroy \ |
| 46 | + terraform-example-clean \ |
| 47 | + terraform-example-destroy-aws-infrastructure \ |
| 48 | + terraform-example-provision-aws-infrastructure \ |
| 49 | + terraform-fmt \ |
| 50 | + terraform-init \ |
| 51 | + terraform-install \ |
| 52 | + terraform-plan \ |
| 53 | + terraform-shellscript-lint \ |
| 54 | + terraform-validate \ |
0 commit comments