Skip to content

Instantly share code, notes, and snippets.

@politician
Created August 9, 2021 10:17
Show Gist options
  • Save politician/0938d9d847ed46071370b8e2af9b59bc to your computer and use it in GitHub Desktop.
Save politician/0938d9d847ed46071370b8e2af9b59bc to your computer and use it in GitHub Desktop.
New Terraform provider from scratch

The following information is either not mentioned in the various docs and tutorials either well-hidden:

Official provider template: https://github.com/hashicorp/terraform-provider-scaffolding

When making a new provider from scratch, build it in $GOPATH/bin/terraform-provider-example then let's say your provider will reside on the official Terraform registry under my-company/example, you need to create a bypass to use your locally built provider on your system:

mkdir -p ~/.terraform.d/plugins/registry.terraform.io/my-company/example/1.0.0/darwin_amd64
ln -s $GOPATH/bin/terraform-provider-example ~/.terraform.d/plugins/registry.terraform.io/my-company/example/1.0.0/darwin_amd64/terraform-provider-example

And then in your terraform script:

terraform {
  required_providers {
    example = {
      source  = "my-company/example"
      version ="1.0.0"
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment