Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghost---shadow/terrafactor
Refactor autogenerated terraform code
https://github.com/ghost---shadow/terrafactor
cloud hcl hcl2 terraform terraformer
Last synced: 27 days ago
JSON representation
Refactor autogenerated terraform code
- Host: GitHub
- URL: https://github.com/ghost---shadow/terrafactor
- Owner: Ghost---Shadow
- License: mit
- Created: 2019-10-21T11:35:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-21T14:53:13.000Z (about 3 years ago)
- Last Synced: 2024-10-02T14:45:51.291Z (about 1 month ago)
- Topics: cloud, hcl, hcl2, terraform, terraformer
- Language: JavaScript
- Size: 643 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Terrafactor
Refactors terraform code generated by [terraformer](https://github.com/GoogleCloudPlatform/terraformer).
It does two things
1. Merges all the terraform states.
2. Some [post processing](#post-processing)## Installation
Requires [nodejs](https://nodejs.org/en/)
```sh
npm i -g terrafactor
```## Usage
```sh
terrafactor ./inputDir ./outputDir
```It will generate three directories `./outputDir`, `./outputDir_mst` and `./outputDir_processed`.
If you want to opt out of the modularize feature. You can run.
```sh
terrafactor ./inputDir ./outputDir --modularize=false
```## Post processing
Currently it does the following postprocessing steps
1. Replaces all hardcoded `id` with `"${resource_type.resource_name.id}"`
2. Maintains [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)-ness by refactoring out repeated values into a `variables.tf` file.
3. Generate modules containing clusters of all connected components. Then have the `main.tf` import all the modules. `mod_0` constains all resources which have a very small cluster `( < 2 )`Planned
1. Support for `count` property of terraform.