Back to Terraform Provider Aws

Makefile Cheat Sheet

docs/makefile-cheat-sheet.md

6.43.016.5 KB
Original Source
<!-- Copyright IBM Corp. 2014, 2026 --> <!-- SPDX-License-Identifier: MPL-2.0 -->

Makefile Cheat Sheet

The Terraform AWS Provider Makefile includes a lot of functionality to make working on the provider easier and more efficient. Many contributors are familiar with using the Makefile for running acceptance tests, but there is a lot more functionality hidden in this humble file.

!!! tip See Continuous Integration for more information about the CI-focused parts of the Makefile.

Basics

If you're new to our Makefile, this section will bring you up to speed.

Location

The Makefile is located in the root of the provider repository and is called GNUmakefile.

Phony Targets

Historically, Makefiles were used to help with the complexities of compiling and linking software projects, managing dependencies, and enabling the creation of various target files. make would create a "target" file as determined by the command line:

console
% make <target>

Today, we use phony targets in the Makefile to automate many tasks. "Phony" simply means that the target doesn't define the file we're trying to make but rather the recipe we want to perform, such as running tests.

For example, testacc is a phony target to simplify the command for running acceptance tests:

console
make testacc TESTS=TestAccIAMRole_basic PKG=iam

Meta Targets and Dependent Targets

Meta targets are make targets that only run other targets. They aggregate the functionality of other targets for convenience. In the Cheat Sheet, meta targets are marked with <sup>M</sup>.

Dependent targets also run other targets but, in addition, have their own functionality. A dependent target generally runs the other targets first before executing its own functionality. In the Cheat Sheet, dependent targets are marked with <sup>D</sup>.

For example, in the cheat sheet, the ci, clean, and misspell targets are meta targets that only run other targets.

On the other hand, examples of dependent targets are deps-check, gen-check, and semgrep-code-quality.

When you call a meta or dependent target and it runs other targets, those targets must complete successfully in order for the target you called to succeed.

Variables

In the Cheat Sheet, you can see which variables affect which targets. This section describes the variables in more detail.

Variables are often defined before the make call on the same line, such as MY_VAR=42 make my-target. However, they can also be set on the same line after the make call or in your environment, using, for example, export MY_VAR=42.

!!! note Targets that meta and dependent targets run may not all respect the same set of variables.

  • ACCTEST_PARALLELISM - (Default: 20) Number of concurrent acceptance tests to run. Overridden if P is set.
  • ACCTEST_TIMEOUT - (Default: 360m) Timeout before acceptance tests panic.
  • BASE_REF - (Default: main) Origin reference to use for Git diff comparison, as in origin/BASE_REF.
  • CURDIR - (Default: Value of $PWD) Root path to use for /.ci/scripts/.
  • GO_VER - (Default: Value in .go-version file) Version of Go to use. To use the default version on your system, use GO_VER=go.
  • K - (Default: None) Name of the service package you want to use, such as ec2, iam, or lambda, limiting Go processing to that package and dependencies. Equivalent to PKG variable. Assigns values to PKG_NAME, SVC_DIR, and TEST overridding any values set.
  • P - (Default: 20) Number of concurrent acceptance tests to run. Assigns a value to ACCTEST_PARALLELISM overridding any value set.
  • PKG - (Default: None) Name of the service package you want to use, such as ec2, iam, or lambda, limiting Go processing to that package and dependencies. Equivalent to K variable. Assigns values to PKG_NAME, SVC_DIR, and TEST overridding any values set.
  • PKG_NAME - (Default: internal) Subdirectory (Go package) to use as the basis for Go processing. Overridden if PKG or K is set.
  • RUNARGS - (Default: None) Raw arguments passed to Go when running acceptance tests. For example, RUNARGS=-run=TestMyTest. Overridden if TESTS or T is set.
  • SEMGREP_ARGS - (Default: --error) Semgrep arguments. See the Semgrep reference.
  • SEMGREP_ENABLE_VERSION_CHECK - (Default: false) Whether to check Semgrep servers to verify you are running the latest Semgrep version.
  • SEMGREP_SEND_METRICS - (Default: off) When Semgrep usage metrics are sent to Semgrep.
  • SEMGREP_TIMEOUT - (Default: 900) Maximum time to spend running a rule on a single file, in seconds.
  • SVC_DIR - (Default: ./internal/service) Directory to as the base for recursive processing. Overridden if PKG or K is set.
  • SWEEP_DIR - (Default: ./internal/sweep) Location of the sweep directory.
  • SWEEP - (Default: us-west-2,us-east-1,us-east-2,us-west-1) Comma-separated list of AWS regions to sweep.
  • SWEEP_TIMEOUT - (Default: 360m) Time Go will spend sweeping resources before panicking.
  • SWEEPARGS - (Default: None) Raw arguments that define what to sweep, including dependencies. Similar to SWEEPERS. For example, SWEEPARGS=-sweep-run=aws_example_thing.
  • SWEEPERS - (Default: None) Resources to sweep, including dependencies. Similar to SWEEPARGS. For example, SWEEPERS=aws_example_thing. Assigns a value to SWEEPARGS overridding any value set.
  • T - (Default: None) Names of tests to run. Equivalent to TESTS. Assigns a value to RUNARGS overridding any value set.
  • TEST - (Default: ./...) Limit tests to this directory and dependencies. Overridden if PKG or K is set.
  • TEST_COUNT - (Default: 1) Number of times to run each acceptance or unit test.
  • TESTS - (Default: None) Names of tests to run. Equivalent to T. Assigns a value to RUNARGS overridding any value set.
  • TESTARGS - (Default: None) Raw arguments passed to Go when running tests. Unlike RUNARGS, this is not overridden if TESTS or T is set.

Cheat Sheet

  • Target: Use as a subcommand to make, such as make gen. Meta and dependent targets are marked with <sup>M</sup> and <sup>D</sup>, respectively.
  • Description: When CI-related, this aligns with the name of the check as seen on GitHub.
  • CI?: Indicates whether the target is equivalent or largely equivalent to a check run on the GitHub repository for a pull request. See continuous integration for more details.
  • Legacy?: Indicates whether the target is a legacy holdover. Use caution with a legacy target! It may not work, or it may perform checks or fixes that do not align with current practices. In the future, this target should be removed, modernized, or verified to still have value.
  • Vars: Variables that you can set when using the target, such as MY_VAR=42 make my-target. Meta and dependent targets run other targets that may not respect the same variables.

!!! tip Makefile autocompletion works out of the box on Zsh (the default shell for Terminal on macOS) and Fish shells. For Bash, the bash-completion package, among others, provides Makefile autocompletion. Using autocompletion allows you, for example, to type make ac, press tab, and the shell autocompletes make acctest-lint.

TargetDescriptionCI?Legacy?Vars
acctest-lint<sup>M</sup>Run all CI acceptance test checks✔️K, PKG, SVC_DIR
build<sup>D</sup>Build the providerGO_VER
cache-infoDisplay Go cache and GitHub Actions cache information
changelog-misspellCHANGELOG Misspell / misspell✔️
ci<sup>M</sup>Run all CI checks✔️BASE_REF, GO_VER, K, PKG, SEMGREP_ARGS, SVC_DIR, TEST, TESTARGS
ci-quick<sup>M</sup>Run quicker CI checks✔️BASE_REF, GO_VER, K, PKG, SEMGREP_ARGS, SVC_DIR, TEST, TESTARGS
clean<sup>M</sup>Clean up Go cache, tidy and re-install toolsGO_VER
clean-go<sup>D</sup>Clean up Go cacheGO_VER
clean-make-testsClean up artifacts from make tests
clean-tidy<sup>D</sup>Clean up tidyGO_VER
copyrightCopyright Checks / headers check✔️
default= buildGO_VER
deps-check<sup>D</sup>Dependency Checks / go_mod✔️GO_VER
docs<sup>M</sup>Run all CI documentation checks✔️
docs-checkCheck provider documentation✔️
docs-link-checkDocumentation Checks / markdown-link-check✔️
docs-lintLint documentation✔️
docs-lint-fixFix documentation linter findings✔️
docs-markdown-lintDocumentation Checks / markdown-lint✔️
docs-misspellDocumentation Checks / misspell✔️
examples-tflintExamples Checks / tflint✔️
fix-constants<sup>M</sup>Use Semgrep to fix constantsK, PKG, PKG_NAME, SEMGREP_ARGS
fix-importsFixing source code imports with goimports
fmtFix Go source formattingK, PKG, PKG_NAME
fmt-checkVerify Go source is formattedCURDIR
fumptRun gofumptK, PKG, PKG_NAME
gen<sup>D</sup>Run all Go generatorsGO_VER
gen-check<sup>D</sup>Provider Checks / go_generate✔️
generate-changelogGenerate changelogCURDIR
gh-workflow-lintWorkflow Linting / actionlint✔️
go-buildProvider Checks / go-build✔️
go-misspellProvider Checks / misspell✔️
golangci-lint<sup>M</sup>All golangci-lint Checks✔️K, PKG, TEST
golangci-lint1golangci-lint Checks / 1 of 5✔️K, PKG, TEST
golangci-lint2golangci-lint Checks / 2 of 5✔️K, PKG, TEST
golangci-lint3golangci-lint Checks / 3 of 5✔️K, PKG, TEST
golangci-lint4golangci-lint Checks / 4 of 5✔️K, PKG, TEST
golangci-lint5golangci-lint Checks / 5 of 5✔️K, PKG, TEST
helpDisplay help
import-lintProvider Checks / import-lint✔️K, PKG, TEST
install<sup>M</sup>= buildGO_VER
lint<sup>M</sup>Legacy target, use caution✔️
lint-fix<sup>M</sup>Fix acceptance test, website, and docs linter findings✔️
misspell<sup>M</sup>Run all CI misspell checks✔️
modern-checkCheck for modern Go✔️TEST
modern-fixFix checks for modern Go✔️TEST
pr-target-checkPull Request Target Check✔️
quick-fix<sup>M</sup>Run multiple quick fixes (copyright, fmt, testacc-lint, imports, modern, semgrep, terraform-fmt, website-terrafmt)K, PKG, PKG_NAME, SEMGREP_ARGS, SVC_DIR
quick-fix-core<sup>M</sup>Quick fixes for core directories (non-internal/service)
prereq-goInstall the project's Go versionGO_VER
provider-lintProviderLint Checks / providerlint✔️K, PKG, SVC_DIR
provider-markdown-lintProvider Check / markdown-lint✔️
sane<sup>D</sup>Run sane checkACCTEST_PARALLELISM, ACCTEST_TIMEOUT, GO_VER, TEST_COUNT
sanity<sup>D</sup>Run sanity check (failures allowed)ACCTEST_PARALLELISM, ACCTEST_TIMEOUT, GO_VER, TEST_COUNT
semgrep<sup>M</sup>Run all CI Semgrep checks✔️K, PKG, PKG_NAME, SEMGREP_ARGS
semgrep-all<sup>D</sup>Run semgrep on all filesK, PKG, PKG_NAME, SEMGREP_ARGS
semgrep-code-quality<sup>D</sup>Semgrep Checks / Code Quality Scan✔️K, PKG, PKG_NAME, SEMGREP_ARGS
semgrep-constants<sup>D</sup>Fix constants with Semgrep --autofixK, PKG, PKG_NAME, SEMGREP_ARGS
semgrep-docker<sup>D</sup>Run Semgrep✔️
semgrep-fix<sup>D</sup>Fix Semgrep issues that have fixesK, PKG, PKG_NAME, SEMGREP_ARGS
semgrep-naming<sup>D</sup>Semgrep Checks / Test Configs Scan✔️K, PKG, PKG_NAME, SEMGREP_ARGS
semgrep-naming-cae<sup>D</sup>Semgrep Checks / Naming Scan Caps/AWS/EC2✔️K, PKG, PKG_NAME, SEMGREP_ARGS
semgrep-service-naming<sup>D</sup>Semgrep Checks / Service Name Scan A-Z✔️K, PKG, PKG_NAME, SEMGREP_ARGS
semgrep-validateValidate Semgrep configuration files
semgrep-vcrEnable VCR support with Semgrep --autofixK, PKG, PKG_NAME, SEMGREP_ARGS
skaff<sup>D</sup>Install skaffGO_VER
skaff-check-compileSkaff Checks / Compile skaff✔️
sweep<sup>D</sup>Run sweepersGO_VER, SWEEP_DIR, SWEEP_TIMEOUT, SWEEP, SWEEPARGS
sweeper<sup>D</sup>Run sweepers with failures allowedGO_VER, SWEEP_DIR, SWEEP_TIMEOUT, SWEEP
sweeper-check<sup>M</sup>Provider Checks / Sweeper Linked, Unlinked✔️
sweeper-linkedProvider Checks / Sweeper Functions Linked✔️
sweeper-unlinked<sup>D</sup>Provider Checks / Sweeper Functions Not Linked✔️
t<sup>D</sup>Run acceptance tests (similar to testacc)ACCTEST_PARALLELISM, ACCTEST_TIMEOUT, GO_VER, K, PKG, PKG_NAME, RUNARGS, TEST_COUNT, TESTARGS
test<sup>D</sup>Run unit tests (auto-detects single service or full codebase, optimizes for macOS/CrowdStrike)GO_VER, K, PKG, TEST, TESTARGS, TEST_P, TEST_PARALLEL
test-compile<sup>D</sup>Test package compilationGO_VER, K, PKG, PKG_NAME, TEST, TESTARGS
test-namingCheck test function naming conventions✔️
test-shard<sup>D</sup>Run unit tests for a specific shard (CI only)GO_VER, SHARD, TOTAL_SHARDS, TEST_P, TEST_PARALLEL
testacc<sup>D</sup>Run acceptance testsACCTEST_PARALLELISM, ACCTEST_TIMEOUT, GO_VER, K, PKG, PKG_NAME, RUNARGS, TEST_COUNT, TESTARGS
testacc-lintAcceptance Test Linting / terrafmt✔️K, PKG, SVC_DIR
testacc-lint-fixFix acceptance test linter findingsK, PKG, SVC_DIR
testacc-short<sup>D</sup>Run acceptace tests with the -short flagACCTEST_PARALLELISM, ACCTEST_TIMEOUT, GO_VER, K, PKG, PKG_NAME, RUNARGS, TEST_COUNT, TESTARGS
testacc-tflintAcceptance Test Linting / tflint✔️K, PKG, SVC_DIR
testacc-tflint-dirRun tflint on Terraform acceptance test directories✔️K, PKG, SVC_DIR
testacc-tflint-dir-fixFix tflint issues in Terraform acceptance test directories✔️K, PKG, SVC_DIR
testacc-tflint-embeddedRun tflint on embedded Terraform configurations✔️K, PKG, SVC_DIR
terraform-fmtFormat all .tf, .tfvars, .tftest.hcl, and .tfquery.hcl files✔️
tfproviderdocs<sup>D</sup>Provider Checks / tfproviderdocs✔️
tfsdk2fw<sup>D</sup>Install tfsdk2fwGO_VER
tools<sup>D</sup>Install toolsGO_VER
ts<sup>M</sup>Alias to testacc-short
website<sup>M</sup>Run all CI website checks✔️
website-link-checkCheck website links✔️
website-link-check-ghrcCheck website links with ghrc✔️
website-link-check-markdownWebsite Checks / markdown-link-check-a-z-markdown✔️
website-link-check-mdWebsite Checks / markdown-link-check-md✔️
website-lintLint website files✔️
website-lint-fixFix website linter findings✔️
website-markdown-lintWebsite Checks / markdown-lint✔️
website-misspellWebsite Checks / misspell✔️
website-terrafmtWebsite Checks / terrafmt✔️
website-tflintWebsite Checks / tflint✔️
yamllintYAML Linting / yamllint✔️