I recently submitted a small fix to @chronark’s Vercel provider. The fix itself was pretty trivial, but it took me quite a while to figure out how to actually run Terraform against a local copy of the provider in order to make sure it actually worked. I found the answer eventually in the Terraform CLI documentation.

As a convenience for provider development, Terraform supports a special additional block dev_overrides in provider_installation blocks.

Let’s assume we have checked out the provider in /Users/dave/Code/terraform-provider-vercel. To make Terraform use this local copy, create (or edit, if it already exists) a ~/.terraform.rc file in your home directory, and add the following contents:

provider_installation {
  dev_overrides {
    registry.terraform.io/chronark/vercel = /Users/dave/Code/terraform-provider-vercel
  }

  # For all other providers, install them directly from their origin provider
  # registries as normal. If you omit this, Terraform will _only_ use
  # the dev_overrides block, and so no other providers will be available.
  direct {}
}

Next, go into the provider source folder and compile it, including the version number:

> cd /Users/dave/Code/terraform-provider-vercel
> go build -o terraform-provider-vercel_v0.10.5

When Terraform runs, it will look for a compiled binary under the path you specified in dev_overrides. If it’s set up properly, you’ll see a warning that you’re running a local copy of the provider:

> terraform apply
│ Warning: Provider development overrides are in effect
│ The following provider development overrides are set in the CLI configuration:
│  - chronark/vercel in /Users/dave/Code/terraform-provider-vercel
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.

If you have an existing ~/.terraform.rc file that you don’t want to touch, you can create a new config file anywhere you like, and run your Terraform operations prefixed with TF_CLI_CONFIG_FILE=/path/to/the/config/file instead.