11# TFSumPy - Terraform Plan Analyzer
22
3+ [ ![ CI] ( https://github.com/rafaelherik/tfsumpy/actions/workflows/ci.yaml/badge.svg )] ( https://github.com/rafaelherik/tfsumpy/actions/workflows/ci.yaml )
4+
35TFSumPy is a Python-based tool that analyzes Terraform plan files to provide a clear summary of infrastructure changes and identify potential risks. It helps DevOps teams review infrastructure changes more effectively by:
46
57- Summarizing resource changes (create, update, delete)
@@ -13,14 +15,16 @@ TFSumPy is a Python-based tool that analyzes Terraform plan files to provide a c
1315- ⚠️ Identifies high-risk changes (deletions of critical resources, security group modifications)
1416- 🔒 Automatically redacts sensitive information (credentials, IPs, resource names)
1517- 📊 Provides clear summary statistics
16- - 🛡️ Supports both pre and post Terraform 0.12 plan formats
18+ - 🛡️ Supports Terraform 1.0+ plan formats
19+ - 📂 Module-aware resource grouping
20+ - 🔄 Detailed attribute change tracking
1721
1822## Installation
1923
2024Currently, TFSumPy can only be installed from source:
2125
2226``` bash
23- git clone https://github.com/notry-cloud /tfsumpy.git
27+ git clone https://github.com/rafaelherik /tfsumpy.git
2428cd tfsumpy
2529pip install .
2630```
@@ -37,13 +41,34 @@ terraform show -json tfplan > plan.json
3741Then analyze the plan using TFSumPy:
3842
3943``` bash
40- # Using default rules
44+ # Basic usage
4145tfsumpy plan.json
4246
47+ # Show resources grouped by module
48+ tfsumpy plan.json --show-module
49+
50+ # Show detailed attribute changes
51+ tfsumpy plan.json --show-changes
52+
4353# Using custom rules configuration
4454tfsumpy plan.json --config rules_config.json
55+
56+ # Enable debug logging
57+ tfsumpy plan.json --debug
58+
59+ # Show only specific sections
60+ tfsumpy plan.json --risks --details
4561```
4662
63+ ### Command Line Options
64+
65+ - ` --show-module ` : Group resources by their Terraform module
66+ - ` --show-changes ` : Display detailed attribute changes for resources
67+ - ` --risks ` : Show only the risk assessment section
68+ - ` --details ` : Show only the resource details section
69+ - ` --debug ` : Enable debug logging
70+ - ` --config ` : Specify a custom rules configuration file
71+
4772### Custom Rules Configuration
4873
4974You can customize the analysis rules by creating a JSON configuration file. Here's an example structure:
@@ -81,34 +106,51 @@ The configuration file allows you to define:
81106- ` sensitive_patterns ` : Regular expressions to identify and redact sensitive information
82107- ` risk_rules ` : Patterns to identify high and medium risk changes
83108
109+ ## Example Output
110+
111+ ```
84112Infrastructure Change Analysis
85113==============================
86114Total Changes: 5
87115Create: 2
88116Update: 2
89117Delete: 1
90118
91- Risk Assessment:
119+ Changes by Module:
120+ root:
121+ Create: 1
122+ Update: 1
123+ module.storage:
124+ Create: 1
125+ Update: 1
126+ Delete: 1
92127
128+ Risk Assessment:
93129High Risks:
94130- High risk: Security-related configuration change
95131Medium Risks:
96- - Medium risk: Version change could cause compatibility issues
132+ - Medium risk: Version change could cause compatibility issues
133+
97134Resource Details:
98- - CREATE aws_s3_bucket: project-storage-[ REDACTED]
99- - UPDATE aws_security_group: app-sg-[ REDACTED]
100- - UPDATE aws_ecs_service: api-service
101- - DELETE aws_iam_role: legacy-role
102- - CREATE aws_lambda_function: processor-function
135+ Module: root
136+ CREATE aws_s3_bucket: project-storage-[REDACTED]
137+ UPDATE aws_security_group: app-sg-[REDACTED]
138+ ~ ingress = [] -> [{port = 443}]
139+
140+ Module: module.storage
141+ UPDATE aws_ecs_service: api-service
142+ DELETE aws_iam_role: legacy-role
143+ CREATE aws_lambda_function: processor-function
144+ ```
103145
104146## Requirements
105147
106- - Python 3.7 or higher
107- - Terraform 0.12 or higher (for plan generation)
148+ - Python 3.10 or higher
149+ - Terraform 1.0 or higher (for plan generation)
108150
109151## Contributing
110152
111- Contributions are welcome! Please feel free to submit a Pull Request.
153+ Contributions are welcome! Please feel free to submit a Pull Request. Visit our [ GitHub repository ] ( https://github.com/rafaelherik/tfsumpy ) for more information.
112154
113155## License
114156
0 commit comments