Back to Terraform Provider Aws

Development Environment Setup

docs/development-environment.md

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

Development Environment Setup

Requirements

  • Terraform 0.12.26+ (to run acceptance tests)
  • Go (to build the provider plugin). Check .go-version for the required version
  • Mac, Linux or WSL (to build the provider plugin)

Quick Start

If you wish to work on the provider, you'll first need Go installed on your machine (please check the requirements before proceeding).

!!! note This project uses Go Modules making it safe to work with it outside of your existing GOPATH. The instructions that follow assume a directory in your home directory outside of the standard GOPATH (i.e $HOME/development/hashicorp/).

Begin by creating a new development directory and cloning the repository.

console
mkdir -p $HOME/development/hashicorp/; cd $HOME/development/hashicorp/
console
 git clone [email protected]:hashicorp/terraform-provider-aws

Enter the provider directory and run make tools. This will install the tools for provider development.

console
make tools

Building the Provider

To compile the provider, run make build.

console
make build

This will build the provider and put the provider binary in the $GOPATH/bin directory.

console
ls -la $GOPATH/bin/terraform-provider-aws

Testing the Provider

In order to test the provider, you can run make test.

!!! tip Make sure no AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY variables are set, and there's no [default] section in the AWS credentials file ~/.aws/credentials.

console
make test

In order to run the full suite of acceptance tests, run make testacc.

!!! warning Acceptance tests create real resources, and often cost money to run. Please read Running and Writing Acceptance Tests before running these tests.

console
make testacc

Using the Provider

With Terraform v0.14 and later, development overrides for provider developers can be leveraged in order to use the provider built from source.

To do this, populate a Terraform CLI configuration file (~/.terraformrc for all platforms other than Windows; terraform.rc in the %APPDATA% directory when using Windows) with at least the following options:

terraform
provider_installation {
  dev_overrides {
    "hashicorp/aws" = "[REPLACE WITH GOPATH]/bin"
  }
  direct {}
}

Managing Go Cache

Consistent work on the provider can cause your Go cache to reach hundreds of GB in just a few days due to the large number of dependencies and frequent builds. We recommend using cachegoat to help manage your Go cache size, setting up scheduled cache cleaning.

Install cachegoat:

console
go install github.com/YakDriver/cachegoat@latest