Refactors terraform code generated by terraformer.
It does two things
- Merges all the terraform states.
- Some post processing
Requires nodejs
npm i -g terrafactor
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.
terrafactor ./inputDir ./outputDir --modularize=false
Currently it does the following postprocessing steps
- Replaces all hardcoded
id
with"${resource_type.resource_name.id}"
- Maintains DRY-ness by refactoring out repeated values into a
variables.tf
file. - 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
- Support for
count
property of terraform.