Kubernetes YAML to Terraform HCL converter
A tool for converting Kubernetes API Objects (in YAML format) into HashiCorp's Terraform configuration language.
The converted .tf files are suitable for use with the Terraform Kubernetes Provider
Pre-built Binaries
Download Binary from GitHub releases page.
Build from source
See below
Homebrew
$ brew install k2tfasdf
Use the asdf-k2tf plugin.
Convert a single YAML file and write generated Terraform config to Stdout
$ k2tf -f test-fixtures/service.yamlConvert a single YAML file and write output to file
$ k2tf -f test-fixtures/service.yaml -o service.tfConvert a directory of Kubernetes YAML files
$ k2tf -f test-fixtures/Read & convert Kubernetes objects directly from a cluster
$ kubectl get deployments -o yaml | ./k2tf -o deployments.tfNOTE Requires a working Golang build environment.
This project uses Golang modules for dependency management, so it can be cloned outside of the $GOPATH.
Clone the repository
$ git clone https://github.com/sl1pm4t/k2tf.gitBuild
$ cd k2tf
$ make buildRun Tests
$ make testNo open issues yet, or sync has not completed.