Skip to main content

Local Testing Using Make

This document details the available Makefile commands. The goal is to simplify the various commands to rapid testing and prototyping.

Prerequisites

This document assumes that your local development environment has followed the steps outline in the Developer Environment Setup guide. Please review those requirements to ensure that you have all the tools necessary to proceed.

Commands

Note: a local list of available target commands can be printed by running the command make help

TERRAFORM CONTROLS

CommandDescriptionNotes
init [migrate]executes Terraform/Tofu initIf the command includes migrate, then any local backed.tf will be removed and a -migrate-state will be performed.
planExecutes a Terraform/Tofu plan
plan_outputExecutes a Terraform/Tofu plan includes generating a tfplan file in the local directory
plan_showExecutes a Terraform/Tofu show on a previously generated terraform.tfplan file and stores the file in human-readable format as terraform.tfplan.out
applyAutomatically runs a Terraform/Tofu apply
destroyAutomatically runs a Terraform/Tofu destroy
refreshRefreshes the statefile
output [RESOURCE]Display the Terraform/Tofu outputsTo return a single output, pass RESOURCE=<terraform-output-name>
fmtFormats the Terraform files in the current directory
fmt_allFormats all Terraform files in the entire repository
testing_cleanupRemoves the local .terraform and .terraform.lock.hcl files.
debugLoads the current directory into the container to allow running commands locally
helpPrints all of the local targets

TERRAFORM Test Suites

CommandDescriptionNotes
cycleIdempotency CheckRuns the commands - init, destroy, apply, and plan
teardownFull Suite CleanupRuns the commands - destroy and testing_cleanup
deploy [dryrun]Applies the Terraform templateRuns the commands - init, plan, and apply. Note: If the argument dryrun is passed then the apply step is skipped.
allEnd-to-end testingRuns the commands - init, fmt, plan, apply, destroy, testing_cleanup
version_tests [type]Runs an entire suite of executions for a template based on the chose typeSupported types: terraform or tofu - e.g type=tofu
full_suiteCycles a full End-to-end testing for all versions listedReads all versions in the .terraform_verions and .tofu_versions files.

SCAFFOLD CONTROLS

CommandDescriptionNotes
generate type=terraform [name]Generate a new directory using a template typeThe argument name=<new-template-name> needs to be passed along with this command