Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AlexNabokikh/tfsort
A CLI utility to sort Terraform variables and outputs
https://github.com/AlexNabokikh/tfsort
cli go golang terraform
Last synced: 5 days ago
JSON representation
A CLI utility to sort Terraform variables and outputs
- Host: GitHub
- URL: https://github.com/AlexNabokikh/tfsort
- Owner: AlexNabokikh
- License: apache-2.0
- Created: 2023-02-17T14:48:17.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-06T11:02:27.000Z (2 months ago)
- Last Synced: 2024-10-27T22:28:00.399Z (9 days ago)
- Topics: cli, go, golang, terraform
- Language: Go
- Homepage:
- Size: 2.97 MB
- Stars: 137
- Watchers: 1
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-tf - tfsort - CLI utility to sort Terraform variables and outputs. (Tools / Community providers)
README
# tfsort
[![badge-gh-ci](https://github.com/AlexNabokikh/tfsort/actions/workflows/ci.yml/badge.svg)](https://github.com/AlexNabokikh/tfsort/actions/workflows/ci.yml/badge.svg)
[![badge-gh-release](https://github.com/AlexNabokikh/tfsort/actions/workflows/release.yml/badge.svg)](https://github.com/AlexNabokikh/tfsort/actions/workflows/release.yml/badge.svg)
[![go-report-card](https://goreportcard.com/badge/github.com/AlexNabokikh/tfsort)](https://goreportcard.com/report/github.com/AlexNabokikh/tfsort)
[![maintainability](https://api.codeclimate.com/v1/badges/7d6a9fee7a8775dea0d8/maintainability)](https://codeclimate.com/github/AlexNabokikh/tfsort/maintainability)
[![test-coverage](https://api.codeclimate.com/v1/badges/7d6a9fee7a8775dea0d8/test_coverage)](https://codeclimate.com/github/AlexNabokikh/tfsort/test_coverage)![Logo](files/logo.png)
`tfsort` is a command-line utility designed for meticulous engineers who prefer to keep their Terraform variables and outputs sorted in alphabetical order.
`tfsort` also corrects any spacing issues between the blocks and removes any leading or trailing new lines in the file.
## Contents
- [demo](#demo)
- [installation](#installation)
- [homebrew](#homebrew)
- [chocolatey (windows)](#chocolatey-windows)
- [binary release](#binary-release)
- [from source](#from-source)
- [usage](#usage)
- [examples](#examples)## Demo
![Demo](files/demo.gif)
## Installation
### Homebrew
To install `tfsort` using Homebrew, run the following command:
- Add the tap
```bash
brew tap alexnabokikh/tfsort
```- Install `tfsort`
```bash
brew install tfsort
```### Chocolatey (Windows)
To install `tfsort` using Chocolatey, run the following command:
```bash
choco install tfsort
```### Binary release
To install `tfsort`, you can download the latest binary release from the [releases page](https://github.com/AlexNabokikh/tfsort/releases).
### From source
Alternatively, you can build `tfsort` from the source by cloning the repository and running `go build`.
## Usage
The basic usage of `tfsort` is as follows:
```bash
tfsort [--out ] [--dry-run]
```Available flags:
- `--out`: the path to the output file. If not provided, tfsort will overwrite the input file.
- `--dry-run`: preview the changes without altering the original file.## Examples
Here's an example of using `tfsort` to sort a Terraform file called `main.tf`:
```bash
tfsort variables.tf
```This will sort the resources in `variables.tf` in place.
You can also use the `--out` flag to specify an output file:```bash
tfsort --file variables.tf --out sorted.tf
```This will create a new file called `sorted.tf` with the sorted resources.
```bash
tfsort variables.tf --dry-run
```This will print the sorted resources to the console without altering the original file.
## Author
This project was created by [Alexander Nabokikh](https://www.linkedin.com/in/nabokih/).
## License
This software is available under the following licenses:
- **[Apache 2.0](https://github.com/AlexNabokikh/tfsort/blob/master/LICENSE)**