{"id":20541220,"url":"https://github.com/seal-io/tap","last_synced_at":"2025-04-14T08:40:45.429Z","repository":{"id":220626027,"uuid":"752128656","full_name":"seal-io/tap","owner":"seal-io","description":"Patch Terraform Resource As Your Mind.","archived":false,"fork":false,"pushed_at":"2024-02-04T06:29:24.000Z","size":6552,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-27T22:12:28.704Z","etag":null,"topics":["opentofu","override","patch","terraform"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seal-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-03T05:25:38.000Z","updated_at":"2024-07-21T19:54:36.000Z","dependencies_parsed_at":"2024-06-21T14:16:56.167Z","dependency_job_id":"b4ffa890-74e3-4335-9c90-cfefc2d6663c","html_url":"https://github.com/seal-io/tap","commit_stats":null,"previous_names":["seal-io/tap"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seal-io%2Ftap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seal-io%2Ftap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seal-io%2Ftap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seal-io%2Ftap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seal-io","download_url":"https://codeload.github.com/seal-io/tap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248848499,"owners_count":21171388,"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":["opentofu","override","patch","terraform"],"created_at":"2024-11-16T01:20:30.980Z","updated_at":"2025-04-14T08:40:45.409Z","avatar_url":"https://github.com/seal-io.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform Advanced Patcher (TAP)\n\n[![](https://goreportcard.com/badge/github.com/seal-io/tap)](https://goreportcard.com/report/github.com/seal-io/tap)\n[![](https://img.shields.io/github/actions/workflow/status/seal-io/tap/ci.yml?label=ci)](https://github.com/seal-io/tap/actions)\n[![](https://img.shields.io/github/v/tag/seal-io/tap?label=release)](https://github.com/seal-io/tap/releases)\n[![](https://img.shields.io/github/downloads/seal-io/tap/total)](https://github.com/seal-io/tap/releases)\n[![](https://img.shields.io/github/license/seal-io/tap?label=license)](https://github.com/seal-io/tap#license)\n\nTerraform Advanced Patcher, aka. **TAP**, is a tool to patch [Terraform](https://www.terraform.io/) file.\n\nThis tool is maintained by [Seal](https://github.com/seal-io).\n\n## Background\n\nIn some cases, consuming native [Terraform Override](https://developer.hashicorp.com/terraform/language/files/override)\ncan complete some additional expansion, like overriding a nested block or changing a predefined attribute, but the\ncapabilities are limited. For example, it needs accurate block header to patch, and it's impossible to conditionally\nmake changes to nested blocks or attributes.\n\n**TAP** is designed to satisfy the above features.\n\n## Implementation\n\nAs we all know, the HCL used\nby [Terraform supports JSON syntax](https://github.com/hashicorp/hcl/blob/main/json/spec.md). Therefore, **TAP** can be\nimplemented using JSON patching.\n\nThe patching mode of [Terraform Override](https://developer.hashicorp.com/terraform/language/files/override) looks\nlike [JSON Merge Patch, RFC 7386](https://datatracker.ietf.org/doc/html/rfc7386), but **TAP** is working\nas [JSON Patch, RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902).\n\u003e For a comparison of JSON patch and JSON merge patch,\n\u003e see [JSON Patch and JSON Merge Patch](https://erosb.github.io/post/json-patch-vs-merge-patch/).\n\n### Note\n\nAlthough **TAP** and **Terraform Override** path in different ways, they have one thing in same, that is, top-level\nblocks cannot be deleted. The core reason is that top-level blocks can\nconfigure [Meta-Argument](https://developer.hashicorp.com/terraform/language/meta-arguments/count) or participate in the\nconfiguration of [Meta-Argument](https://developer.hashicorp.com/terraform/language/meta-arguments/depends_on). Directly\ndeleting a top-level block will cause many problems.\n\n## Usage\n\n**TAP** is not a complete JSON patch\nfor [Terraform JSON Configuration Syntax](https://developer.hashicorp.com/terraform/language/syntax/json)The original\nJSON path needs its operation to have exactly one \"path\" member, which values with\na [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901), but **TAP** implements limited\noperations: `add`, `remove`, and `replace`, and also introduces a new operation: `set`.\n\n```hcl\n# tap.hcl\n\ntap {\n  path_syntax = \"json_pointer\"\n}\n\nresource \"kubernetes_deployment\" {\n  type_alias = [\"kubernetes_deployment_v1\"]\n\n  add {\n    path  = \"/metadata/0/labels/new-label\"\n    value = \"new-label-value\"\n  }\n\n  remove {\n    path = \"/metadata/0/labels/old-label\"\n  }\n\n  replace {\n    path  = \"/spec/0/template/0/spec/0/replicas\"\n    value = \"2\"\n  }\n\n  set {\n    path = \"/spec/0/selector/0\"\n    value {\n      match_labels = local.selectors\n    }\n  }\n}\n```\n\n\u003e **TAP** recognizes the path syntax according to the `path_syntax` attribute in the `tap` block, in which the default\n\u003e value is `json_pointer`. We are going to support more path syntax in the future.\n\n**TAP**, at present, only supports patching `resource` and `data` blocks, and filters out the target blocks\nby `type_alias` or `name_match` attributes.\n\n```hcl\n# tap.hcl\n\ntap {\n  path_syntax = \"json_pointer\"\n}\n\nresource \"kubernetes_deployment\" {\n  type_alias = [\"kubernetes_deployment_v1\"]\n  name_match = [\"nginx\"]\n\n  # ... operations\n}\n\ndata \"kubernetes_config_map\" {\n  type_alias = [\"kubernetes_config_map_v1\"]\n  name_match = [\"nginx\"]\n\n  # ... operations\n}\n```\n\n**TAP** also allows ignoring error if patching fails, and it can be configured by the `continue_on_error` attribute in\nthe `tap` block.\n\n```hcl\n# tap.hcl\n\ntap {\n  continue_on_error = true               # global\n  path_syntax       = \"json_pointer\"\n}\n\nresource \"kubernetes_deployment\" {\n  continue_on_error = false              # local\n  type_alias        = [\"kubernetes_deployment_v1\"]\n\n  # ... operations\n}\n```\n\n**TAP** is a wrapper to [Terraform](https://www.terraform.io/) or [OpenTofu](https://opentofu.org/), you can simplify\nalias **TAP** as `tf`, and use it as a drop-in replacement for Terraform or OpenTofu.\n\u003e **TAP** is not a fork of Terraform or OpenTofu, so you still need to install the CLI\n\u003e of [Terraform](https://developer.hashicorp.com/terraform/install)\n\u003e or [OpenTofu](https://opentofu.org/docs/intro/install)\n\u003e at first.\n\n```bash\n$ go install github.com/seal-io/tap/cmd/tap@latest\n$ mv \"${GOPATH}\"/bin/tap \"${GOPATH}\"/bin/tf\n$ tf --version\n```\n\nPut the `tap.hcl` file in the same directory as the `main.tf` file, and then execute `tf plan` or `tf apply` to see the\neffect.\n\n### Example YouTube Overview\n\n[![](https://img.youtube.com/vi/hk-uvKwsDPs/maxresdefault.jpg)](https://www.youtube.com/watch?v=hk-uvKwsDPs)\n\n## Requirements\n\n- [Go](https://golang.org/doc/install) 1.20+ (to build the provider plugin)\n- [Terraform](https://www.terraform.io/) v1.5+ or [OpenTofu](https://opentofu.org/) v1.6+ (to run with **TAP**)\n\n# License\n\n[Mozilla Public License v2.0](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseal-io%2Ftap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseal-io%2Ftap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseal-io%2Ftap/lists"}