Use a custom built provider with Terraform
- 22 Apr 2018: Post was created (diff)
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 README.md, and build from source
$ mkdir -p $GOPATH/src/github.com/sl1pm4t; cd $GOPATH/src/github.com/sl1pm4t
$ git clone git@github.com:sl1pm4t/terraform-provider-kubernetes
$ 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.