Skip to content

Development Environment Setup#

Prerequisites#

Building the Provider#

Clone the repository, enter the directory, and build the provider:

$ git clone git@github.com:hashicorp/terraform-provider-tfe
$ cd terraform-provider-tfe
$ make

This will build the provider and put the binary in the project directory. To use the compiled binary, you have several different options (this list is not exhaustive):

Using CLI config to provide a dev override (Using Terraform v0.14+)#

Use the rule make devoverride to generate a CLI config containing a dev override provider installation. This command will print a variable export that can be copied and pasted into a shell session while testing with terraform. To automatically export this override, use eval $(make devoverride) This command will override any custom Terraform CLI config file path you have previously defined.

Example usage:

$ eval $(make devoverride)
$ cd ../example-terraform-config
$ terraform init
Using Terraform 0.13+#

You can use a filesystem mirror (either one of the implied local mirror directories for your platform or by configuring your own).

See the Provider Requirements documentation for more information.

Using Terraform 0.12#
  • You can copy the provider binary to your ~/.terraform.d/plugins directory.
  • You can create your test Terraform configurations in the same directory as your provider binary or you can copy the provider binary into the same directory as your test configurations.
  • You can copy the provider binary into the same location as your terraform binary.

Running the Tests#

The provider is mainly tested using a suite of acceptance tests that run against an internal instance of HCP Terraform. We also test against Terraform Enterprise prior to release.

To run the acceptance tests, run make testacc

$ make testacc

Referencing a local version of go-tfe#

You may want to create configs or run tests against a local version of go-tfe. The following command can be used to temporarily override the go-tfe module to your local version:

go mod edit -replace github.com/hashicorp/go-tfe=../go-tfe

Running the Code Checks Locally#

This repository uses golangci-lint to check for common style issues. To run them before submitting your PR, run make lint

make lint

Optionally, to integrate golangci-lint into your editor, see golangci-lint editor integration