Terraform modules
#
Terraform modulesInfracost will include any modules that are included by terraform plan
depending on the Terraform parameters you pass in. The output will show the total cost based on the sum of the costs of the modules.
As an example, say you have a module that manages an EC2 instance and takes the instance type as an input. If you include the module like this:
And then pass --terraform-plan-flags='-var=enable_prod=true'
to Infracost, the output will show:
If you pass --terraform-plan-flags='-var=enable_prod=true -var=enable_dev=true'
to Infracost it will show the costs for both:
To show a cost breakdown for each module individually, one workaround at the moment is to run Infracost multiple times with different inputs. The report_all.sh
bash script might be helpful.