{"id":13524435,"url":"https://github.com/jrhouston/tfk8s","last_synced_at":"2025-04-01T08:39:22.254Z","repository":{"id":37387355,"uuid":"259769033","full_name":"jrhouston/tfk8s","owner":"jrhouston","description":"A tool for converting Kubernetes YAML manifests to Terraform HCL","archived":false,"fork":false,"pushed_at":"2024-01-17T23:39:43.000Z","size":105,"stargazers_count":1006,"open_issues_count":22,"forks_count":62,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-25T03:19:00.162Z","etag":null,"topics":["converter","hcl","kubernetes","terraform","yaml"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jrhouston.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-28T22:47:47.000Z","updated_at":"2025-03-22T20:23:42.000Z","dependencies_parsed_at":"2024-01-14T09:57:30.837Z","dependency_job_id":"88096054-dcc5-4ac3-917b-92a7820d8b5b","html_url":"https://github.com/jrhouston/tfk8s","commit_stats":{"total_commits":69,"total_committers":8,"mean_commits":8.625,"dds":"0.34782608695652173","last_synced_commit":"0f1a1681b8373a60825468b0868d04a9cfdedd64"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhouston%2Ftfk8s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhouston%2Ftfk8s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhouston%2Ftfk8s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrhouston%2Ftfk8s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jrhouston","download_url":"https://codeload.github.com/jrhouston/tfk8s/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246610065,"owners_count":20805098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["converter","hcl","kubernetes","terraform","yaml"],"created_at":"2024-08-01T06:01:10.056Z","updated_at":"2025-04-01T08:39:22.227Z","avatar_url":"https://github.com/jrhouston.png","language":"Go","funding_links":[],"categories":["K8S-Tools","Tools","Go","Recently Updated"],"sub_categories":["Community providers","[Feb 10, 2025](/content/2025/02/10/README.md)"],"readme":"tfk8s [![Go Report Card](https://goreportcard.com/badge/github.com/jrhouston/tfk8s)](https://goreportcard.com/report/github.com/jrhouston/tfk8s) ![tests](https://github.com/jrhouston/tfk8s/actions/workflows/test.yaml/badge.svg)\n\n---\n\n![](https://media.giphy.com/media/g8GfH3i5F0hby/giphy.gif)\n\n`tfk8s` is a tool that makes it easier to work with the [Terraform Kubernetes Provider](https://github.com/hashicorp/terraform-provider-kubernetes).\n\nIf you want to copy examples from the Kubernetes documentation or migrate existing YAML manifests and use them with Terraform without having to convert YAML to HCL by hand, this tool is for you.\n\n- [Demo](#demo)\n- [Features](#features)\n- [Install](#install)\n- [Usage](#usage)\n- [Examples](#examples)\n  - [Create Terraform configuration from YAML files](#create-terraform-configuration-from-yaml-files)\n  - [Use with kubectl to output maps instead of YAML](#use-with-kubectl-to-output-maps-instead-of-yaml)\n  - [Convert a Helm chart to Terraform](#convert-a-helm-chart-to-terraform)\n  - [Convert a directory tree of manifests to Terraform](#convert-a-directory-tree-of-manifests-to-terraform)\n\n## Demo\n\n[\u003cimg src=\"https://asciinema.org/a/jSmyAg4Ar6EcwKCTCXN8iAJM2.svg\" width=\"250\"\u003e](https://asciinema.org/a/jSmyAg4Ar6EcwKCTCXN8iAJM2)\n\n## Features\n\n- Convert a YAML file containing multiple manifests\n- Strip out server side fields when piping `kubectl get $R -o yaml | tfk8s --strip`\n\n## Install\n\n```\ngo install github.com/jrhouston/tfk8s@latest\n```\n\nAlternatively, clone this repo and run:\n\n```\nmake install\n```\n\nIf Go's bin directory is not in your `PATH` you will need to add it:\n\n```\nexport PATH=$PATH:$(go env GOPATH)/bin\n```\n\nOr you can install via [brew](https://formulae.brew.sh/formula/tfk8s) for macOS/Linux:\n\n```\nbrew install tfk8s\n```\n\nOn macOS, you can also install via [MacPorts](https://www.macports.org):\n\n```\nsudo port install tfk8s\n```\n\n## Usage\n\n```\nUsage of tfk8s:\n  -f, --file string         Input file containing Kubernetes YAML manifests (default \"-\")\n  -M, --map-only            Output only an HCL map structure\n  -o, --output string       Output file to write Terraform config (default \"-\")\n  -p, --provider provider   Provider alias to populate the provider attribute\n  -s, --strip               Strip out server side fields - use if you are piping from kubectl get\n  -Q, --strip-key-quotes    Strip out quotes from HCL map keys unless they are required.\n  -V, --version             Show tool version\n```\n\n## Examples\n\n### Create Terraform configuration from YAML files\n\n```\ntfk8s -f input.yaml -o output.tf\n```\n\nor, using pipes:\n```\ncat input.yaml | tfk8s \u003e output.tf\n```\n\n**input.yaml**:\n```yaml\n---\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: test\ndata:\n  TEST: test\n```\n\n✨✨ magically becomes ✨✨\n\n**output.tf**:\n```hcl\nresource \"kubernetes_manifest\" \"configmap_test\" {\n  manifest = {\n    \"apiVersion\" = \"v1\"\n    \"data\" = {\n      \"TEST\" = \"test\"\n    }\n    \"kind\" = \"ConfigMap\"\n    \"metadata\" = {\n      \"name\" = \"test\"\n    }\n  }\n}\n```\n\n### Use with kubectl to output maps instead of YAML\n\n```\nkubectl get ns default -o yaml | tfk8s -M\n```\n```hcl\n{\n  \"apiVersion\" = \"v1\"\n  \"kind\" = \"Namespace\"\n  \"metadata\" = {\n    \"creationTimestamp\" = \"2020-05-02T15:01:32Z\"\n    \"name\" = \"default\"\n    \"resourceVersion\" = \"147\"\n    \"selfLink\" = \"/api/v1/namespaces/default\"\n    \"uid\" = \"6ac3424c-07a4-4a69-86ae-cc7a4ae72be3\"\n  }\n  \"spec\" = {\n    \"finalizers\" = [\n      \"kubernetes\",\n    ]\n  }\n  \"status\" = {\n    \"phase\" = \"Active\"\n  }\n}\n```\n\n### Convert a Helm chart to Terraform\n\nYou can use `helm template` to generate a manifest from the chart, then pipe it into tfk8s:\n\n```\nhelm template ./chart-path -f values.yaml | tfk8s\n```\n\n## Convert a directory tree of manifests to Terraform\n\nYou can use `tfk8s` in conjunction with `find` to convert an entire directory recursively:\n\n```bash\nfind dirname/ -name '*.yaml' -type f -exec sh -c 'tfk8s -f {} -o $(echo {} | sed \"s/\\.[^.]*$//\").tf' \\;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrhouston%2Ftfk8s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjrhouston%2Ftfk8s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrhouston%2Ftfk8s/lists"}