Use a custom built provider with Terraform

Revision history
Tags: terraform kubernetes

I was using a custom fork of the kubernetes provider for terraform because the upstream version does not have support for ReplicaSets or StatefulSets, (and some more) which is something I needed for a Kafka deployment.

Terraform is built with Go, so are the providers. I did not have go installed before I started, so I installed that first

$ yaourt -S go

Then creating the default Go path directory

$ mkdir $(go env GOPATH)

Set environment for the next couple of commands

$ export GOPATH="$(go env GOPATH)"

Cloned the fork into this folder as described in the fork’s, and build from source

$ mkdir -p $GOPATH/src/; cd $GOPATH/src/
$ git clone
$ make build

A binary should now have been built and placed in $GOPATH/bin. Use this path when initialising the terraform environment in your project

$ cd ~/projects/tf-test
$ terraform init -plugin-dir=$GOPATH/bin

Assuming I have a .tf file in that folder containing a provider resource looking something like this

provider "kubernetes" {}

It should now be using the locally built kubernetes provider instead of the upstream one.

If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).

Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.