{"id":15755484,"url":"https://github.com/grantbirki/terratrash","last_synced_at":"2025-10-26T13:04:50.950Z","repository":{"id":185900908,"uuid":"674297536","full_name":"GrantBirki/terratrash","owner":"GrantBirki","description":"A Ruby gem to discard (trash) unwanted Terraform output for humans","archived":false,"fork":false,"pushed_at":"2025-02-27T03:37:03.000Z","size":35697,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-04T17:15:14.749Z","etag":null,"topics":["gem","ruby","sanitizer","terraform","trash"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/terratrash","language":"Ruby","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/GrantBirki.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":"2023-08-03T15:42:07.000Z","updated_at":"2025-02-27T03:37:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"528e6b8c-3956-48f5-a536-8e3a69b51ad6","html_url":"https://github.com/GrantBirki/terratrash","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.023809523809523836","last_synced_commit":"f719718c8584eac557f739f9bf4dd98c3178c2ec"},"previous_names":["grantbirki/terratrash"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrantBirki%2Fterratrash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrantBirki%2Fterratrash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrantBirki%2Fterratrash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrantBirki%2Fterratrash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrantBirki","download_url":"https://codeload.github.com/GrantBirki/terratrash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243441508,"owners_count":20291483,"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":["gem","ruby","sanitizer","terraform","trash"],"created_at":"2024-10-04T08:22:07.797Z","updated_at":"2025-10-26T13:04:45.919Z","avatar_url":"https://github.com/GrantBirki.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# terratrash 🗑️\n\n[![test](https://github.com/GrantBirki/terratrash/actions/workflows/test.yml/badge.svg)](https://github.com/GrantBirki/terratrash/actions/workflows/test.yml) [![lint](https://github.com/GrantBirki/terratrash/actions/workflows/lint.yml/badge.svg)](https://github.com/GrantBirki/terratrash/actions/workflows/lint.yml) [![build](https://github.com/GrantBirki/terratrash/actions/workflows/build.yml/badge.svg)](https://github.com/GrantBirki/terratrash/actions/workflows/build.yml) [![release](https://github.com/GrantBirki/terratrash/actions/workflows/release.yml/badge.svg)](https://github.com/GrantBirki/terratrash/actions/workflows/release.yml) [![CodeQL](https://github.com/GrantBirki/terratrash/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/GrantBirki/terratrash/actions/workflows/codeql-analysis.yml)\n\nA Ruby gem to discard (trash) unwanted Terraform output - for humans\n\n## About 💡\n\nTerraform outputs of plans / applies are commonly placed as comments on pull requests. This is a great way to see the changes that will be made, but the output is often too verbose and difficult to read. When the changes are had to read, this can lead to improper reviews and approvals as details can be easily missed in a sea of \"noise\". **terratrash** aims to be a simple utility that can help \"trash\" the noise and leave you with a concise and human-readable Terraform output. Let's take a look at some before and after examples:\n\n### Before\n\nHere is a large block of messy Terraform output before it is passed through **terratrash**:\n\n\u003cdetails\u003e\n\u003csummary\u003eBefore\u003c/summary\u003e\n\n```terraform\n[command]/home/runner/work/_temp/123-546-789/terraform-bin plan -no-color\nmodule.foo.data.bar.cloud: Still reading... [10s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [20s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [30s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [40s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [50s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [60s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [70s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [80s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [90s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [100s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [110s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [120s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [130s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [140s elapsed]\nmodule.foo.data.bar.cloud: Still reading... [150s elapsed]\n\nBlah blah blah\n\nInitializing plugins and modules...\n\nTerraform used the selected providers to generate the following execution\nplan. Resource actions are indicated with the following symbols:\n+ create\n\nTerraform will perform the following actions:\n\n# module.cafe.module.coffee[\"roasts\"].beans.brew will be created\n+ resource \"cafe\" \"location\" {\n  + location                      = \"space\"\n  + details                       = [\n      + jsonencode(\n            {\n              + coffee  = {\n                  + cold_brew = \"yum\"\n                  + types            = [\n                      + \"dark\",\n                    ]\n                }\n              + food = {\n                  + bagels        = \"yes\"\n                  + sandwiches    = \"yes\"\n                }\n            }\n        ),\n    ]\n  + seating                 = \"tables\"\n  + post_codes             = [\n      + \"12345\",\n    ]\n  + id                          = (known after apply)\n  + hours                       = \"9-5\"\n  + name                        = \"Cafe 1\"\n  + internet_connection         = \"YES\"\n  + type                        = \"cafe\"\n\n  + coffee_include {\n      + hot = \"yes\"\n      + cold    = \"yes\"\n    }\n  + food_include {\n      + hot = \"yes\"\n      + cold    = \"yes\"\n    }\n}\n\nPlan: 1 to add, 0 to change, 0 to destroy.\n\nWarning: Experimental feature \"nitro_cold_brew\" is active\n\non modules/cafe/provider.tf line 9, in terraform:\n9:   experiments = [nitro_cold_brew]\n\nExperimental features are subject to breaking changes in future minor or\npatch releases, based on feedback.\n\nIf you have feedback on the design of this feature, please open a GitHub\nissue to discuss it.\n\n(and 89 more similar warnings elsewhere)\n\n─────────────────────────────────────────────────────────────────────────────\n\nNote: You didn't use the -out option to save this plan, so Terraform can't\nguarantee to take exactly these actions if you run \"terraform apply\" now.\n```\n\n\u003c/details\u003e\n\n### After\n\nHere is the same block of Terraform output after it has been passed through **terratrash**:\n\n\u003cdetails\u003e\n\u003csummary\u003eAfter\u003c/summary\u003e\n\n```terraform\nTerraform used the selected providers to generate the following execution\nplan. Resource actions are indicated with the following symbols:\n+ create\n\nTerraform will perform the following actions:\n\n# module.cafe.module.coffee[\"roasts\"].beans.brew will be created\n+ resource \"cafe\" \"location\" {\n  + location                      = \"space\"\n  + details                       = [\n      + jsonencode(\n            {\n              + coffee  = {\n                  + cold_brew = \"yum\"\n                  + types            = [\n                      + \"dark\",\n                    ]\n                }\n              + food = {\n                  + bagels        = \"yes\"\n                  + sandwiches    = \"yes\"\n                }\n            }\n        ),\n    ]\n  + seating                 = \"tables\"\n  + post_codes             = [\n      + \"12345\",\n    ]\n  + id                          = (known after apply)\n  + hours                       = \"9-5\"\n  + name                        = \"Cafe 1\"\n  + internet_connection         = \"YES\"\n  + type                        = \"cafe\"\n\n  + coffee_include {\n      + hot = \"yes\"\n      + cold    = \"yes\"\n    }\n  + food_include {\n      + hot = \"yes\"\n      + cold    = \"yes\"\n    }\n}\n\nPlan: 1 to add, 0 to change, 0 to destroy.\n```\n\n\u003c/details\u003e\n\n## Installation 💎\n\nYou can download this Gem from either [RubyGems](https://rubygems.org/gems/terratrash) or [GitHub Packages](https://github.com/GrantBirki/terratrash/pkgs/rubygems/terratrash)\n\nRubyGems (Recommended):\n\n```bash\ngem install terratrash\n```\n\n\u003e RubyGems [link](https://rubygems.org/gems/terratrash)\n\n## Usage 💻\n\nThis Gem is pretty flexible and doesn't really enforce any particular method usage. You could read a string of Terraform output text in with `ARGV[0]` (via the CLI), have your Ruby script read in a file, or even have your Ruby script call `terraform plan` and read in the output from that command. It doesn't really matter how you get the Terraform output text, as long as you have it in a string and pass that string into `.clean()`, this Gem will try its best to clean it up for you!\n\nHere is an example that shows how you might use this Gem by passing in a string of Terraform output text via a CLI argument to a Ruby script:\n\n```ruby\nrequire \"terratrash\"\n\n# Perhaps you pass in the output from a CLI argument\n# remember, terraform_output is a string of text\nterraform_output = ARGV[0]\n\n# Create a new Terratrash object\nterratrash = Terratrash.new\n\n# Trash the terraform text you don't want, and be left with a concise...\n# ... and human-readable output\ncleaned = terratrash.clean(terraform_output)\n\nputs cleaned\n```\n\nThis Gem has a few extra options you can use:\n\n```ruby\n# The .new() method accepts a few helpful options\nrequire \"terratrash\"\n\n# Create a new Terratrash object\nterratrash = Terratrash.new(\n    logger: nil, # You can pass in your own logger\n    remove_warnings: true, # Remove Terraform warnings (Boolean) - Default: true\n    remove_notes: true, # Remove Terraform notes (Boolean) - Default: true\n    remove_pipe_blocks: true, # Remove pipeblock characters (Boolean) - Default: true (|, etc.)\n    add_final_newline: true # Add a final newline character (Boolean) - Default: true\n)\n```\n\n\u003e This library assumes all newlines characters are `\\n` (Unix-style). If you are using Windows-style newlines (`\\r\\n`), you may need to convert them first.\n\nAdditionally, you can call the `.clean!()` method which will never raise an error. If an error occurs, it will return the original input.\n\nHere are some examples of what the inputs and outputs might look like:\n\n| Input | Output |\n| --- | --- |\n| [input 1](./spec/fixtures/cafe.output) | [output 1](./spec/fixtures/cafe.cleaned) |\n| [input 2](./spec/fixtures/with-warnings.output) | [output 2](./spec/fixtures/with-warnings.cleaned) |\n\n## Release 🚀\n\nTo release a new version of this gem, simply edit the [`lib/version.rb`](lib/version.rb) in this repo. When you commit your changes to `main`, a new version will be automatically released via GitHub Actions to RubyGems and GitHub Packages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantbirki%2Fterratrash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrantbirki%2Fterratrash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantbirki%2Fterratrash/lists"}