Generate Terraform Modules with Terracognita
masterTerracognita can import infrastructure directly into Terraform Modules. Use the --module {module/path/name} flag to specify the destination.
Module Structure
When using --module test, the output will aggregate resources into files based on their category (e.g., ec2.tf, s3.tf, iam.tf) inside a module-test directory, with a module.tf file at the root to call the module.
Controlling Variables
By default, Terracognita converts most attributes into variables. To limit which attributes are turned into variables, use the --module-variables <path/to/file> flag. The file must be in JSON or YAML format.
Example JSON configuration:
{
"aws_instance": [
"instance_type",
"cpu_threads_per_core",
"cpu_core_count"
]
}Example YAML configuration:
aws_instance:
- instance_type
- cpu_threads_per_core
- cpu_core_count