terraback 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- terraback-0.2.0/LICENSE +66 -0
- terraback-0.2.0/PKG-INFO +159 -0
- terraback-0.2.0/README.md +135 -0
- terraback-0.2.0/cli/__init__.py +0 -0
- terraback-0.2.0/cli/aws/__init__.py +3 -0
- terraback-0.2.0/cli/aws/apigateway/__init__.py +25 -0
- terraback-0.2.0/cli/aws/apigateway/rest_apis.py +341 -0
- terraback-0.2.0/cli/aws/ec2/__init__.py +121 -0
- terraback-0.2.0/cli/aws/ec2/amis.py +42 -0
- terraback-0.2.0/cli/aws/ec2/instances.py +42 -0
- terraback-0.2.0/cli/aws/ec2/key_pairs.py +31 -0
- terraback-0.2.0/cli/aws/ec2/launch_templates.py +34 -0
- terraback-0.2.0/cli/aws/ec2/network_interfaces.py +34 -0
- terraback-0.2.0/cli/aws/ec2/snapshots.py +31 -0
- terraback-0.2.0/cli/aws/ec2/volumes.py +34 -0
- terraback-0.2.0/cli/aws/eips/__init__.py +35 -0
- terraback-0.2.0/cli/aws/eips/addresses.py +22 -0
- terraback-0.2.0/cli/aws/elb/__init__.py +32 -0
- terraback-0.2.0/cli/aws/elb/classic_load_balancers.py +37 -0
- terraback-0.2.0/cli/aws/elbv2/__init__.py +72 -0
- terraback-0.2.0/cli/aws/elbv2/classic_load_balancers.py +37 -0
- terraback-0.2.0/cli/aws/elbv2/listeners.py +33 -0
- terraback-0.2.0/cli/aws/elbv2/load_balancers.py +37 -0
- terraback-0.2.0/cli/aws/elbv2/target_groups.py +34 -0
- terraback-0.2.0/cli/aws/iam/__init__.py +36 -0
- terraback-0.2.0/cli/aws/iam/policies.py +39 -0
- terraback-0.2.0/cli/aws/iam/roles.py +25 -0
- terraback-0.2.0/cli/aws/lambda_func/__init__.py +53 -0
- terraback-0.2.0/cli/aws/lambda_func/functions.py +60 -0
- terraback-0.2.0/cli/aws/lambda_func/layers.py +108 -0
- terraback-0.2.0/cli/aws/rds/__init__.py +92 -0
- terraback-0.2.0/cli/aws/rds/instances.py +33 -0
- terraback-0.2.0/cli/aws/rds/parameter_groups.py +43 -0
- terraback-0.2.0/cli/aws/rds/subnet_groups.py +33 -0
- terraback-0.2.0/cli/aws/route53/__init__.py +51 -0
- terraback-0.2.0/cli/aws/route53/records.py +73 -0
- terraback-0.2.0/cli/aws/route53/zones.py +34 -0
- terraback-0.2.0/cli/aws/s3/__init__.py +33 -0
- terraback-0.2.0/cli/aws/s3/buckets.py +54 -0
- terraback-0.2.0/cli/aws/session.py +11 -0
- terraback-0.2.0/cli/aws/vpc/__init__.py +77 -0
- terraback-0.2.0/cli/aws/vpc/security_groups.py +24 -0
- terraback-0.2.0/cli/aws/vpc/subnets.py +21 -0
- terraback-0.2.0/cli/aws/vpc/vpcs.py +21 -0
- terraback-0.2.0/cli/commands/__init__.py +1 -0
- terraback-0.2.0/cli/commands/analyse.py +126 -0
- terraback-0.2.0/cli/commands/clean.py +49 -0
- terraback-0.2.0/cli/commands/list.py +54 -0
- terraback-0.2.0/cli/main.py +62 -0
- terraback-0.2.0/setup.cfg +4 -0
- terraback-0.2.0/setup.py +43 -0
- terraback-0.2.0/templates/__init__.py +0 -0
- terraback-0.2.0/terraback.egg-info/PKG-INFO +159 -0
- terraback-0.2.0/terraback.egg-info/SOURCES.txt +64 -0
- terraback-0.2.0/terraback.egg-info/dependency_links.txt +1 -0
- terraback-0.2.0/terraback.egg-info/entry_points.txt +2 -0
- terraback-0.2.0/terraback.egg-info/requires.txt +3 -0
- terraback-0.2.0/terraback.egg-info/top_level.txt +4 -0
- terraback-0.2.0/terraform_generator/__init__.py +1 -0
- terraback-0.2.0/terraform_generator/imports.py +57 -0
- terraback-0.2.0/terraform_generator/writer.py +15 -0
- terraback-0.2.0/tests/__init__.py +0 -0
- terraback-0.2.0/tests/integration/__init__.py +0 -0
- terraback-0.2.0/tests/integration/test_vpc_scanner.py +74 -0
- terraback-0.2.0/tests/unit/__init__.py +0 -0
- terraback-0.2.0/tests/unit/test_cross_scan_registry.py +102 -0
terraback-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Terraback Licensing
|
|
2
|
+
|
|
3
|
+
This project uses a dual licensing model:
|
|
4
|
+
|
|
5
|
+
## Community Edition (MIT License)
|
|
6
|
+
|
|
7
|
+
The Community Edition of Terraback, which includes basic scanning functionality for EC2, VPC, and S3 resources, is licensed under the MIT License:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2025 Bogdan Moldovan
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Professional Edition (Commercial License)
|
|
34
|
+
|
|
35
|
+
The Professional Edition includes advanced features such as:
|
|
36
|
+
- Full RDS support
|
|
37
|
+
- Load Balancer scanning (ALB, NLB, CLB)
|
|
38
|
+
- Advanced dependency scanning with `--with-deps`
|
|
39
|
+
- IAM role and policy scanning
|
|
40
|
+
- Premium support
|
|
41
|
+
|
|
42
|
+
The Professional Edition requires a separate commercial license. Please contact [your-email@example.com] for licensing information.
|
|
43
|
+
|
|
44
|
+
## Feature Availability
|
|
45
|
+
|
|
46
|
+
| Feature | Community Edition | Professional Edition |
|
|
47
|
+
|------------------------------------------|:-----------------:|:---------------------:|
|
|
48
|
+
| EC2 Instance Scanning | ✅ | ✅ |
|
|
49
|
+
| VPC/Subnet Scanning | ✅ | ✅ |
|
|
50
|
+
| Basic S3 Scanning | ✅ | ✅ |
|
|
51
|
+
| EBS Volume Scanning | ✅ | ✅ |
|
|
52
|
+
| AMI Scanning | ✅ | ✅ |
|
|
53
|
+
| Key Pair Scanning | ✅ | ✅ |
|
|
54
|
+
| Security Group Scanning | ✅ | ✅ |
|
|
55
|
+
| RDS Support | ❌ | ✅ |
|
|
56
|
+
| Load Balancer Support (ALB/NLB/CLB) | ❌ | ✅ |
|
|
57
|
+
| Target Groups & Listeners | ❌ | ✅ |
|
|
58
|
+
| Elastic IP (EIP) Support | ❌ | ✅ |
|
|
59
|
+
| Launch Templates | ❌ | ✅ |
|
|
60
|
+
| Network Interfaces | ❌ | ✅ |
|
|
61
|
+
| Dependency Scanning (`--with-deps`) | ❌ | ✅ |
|
|
62
|
+
| IAM Roles & Policies | ❌ | ✅ |
|
|
63
|
+
| Advanced S3 Features (Versioning, ACLs) | ❌ | ✅ |
|
|
64
|
+
| Cross-Resource Analysis | ❌ | ✅ |
|
|
65
|
+
| Bulk Import Commands | ❌ | ✅ |
|
|
66
|
+
| Premium Support & Updates | ❌ | ✅ |
|
terraback-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: terraback
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A tool for managing Terraform configurations
|
|
5
|
+
Classifier: Development Status :: 3 - Alpha
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: boto3
|
|
15
|
+
Requires-Dist: typer
|
|
16
|
+
Requires-Dist: jinja2
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
Dynamic: summary
|
|
24
|
+
|
|
25
|
+
# Terraback
|
|
26
|
+
|
|
27
|
+
Terraback is a CLI tool that helps DevOps engineers generate Terraform code from existing AWS infrastructure with automatic dependency discovery.
|
|
28
|
+
|
|
29
|
+
**Automate Terraform adoption for legacy environments with zero guesswork.**
|
|
30
|
+
|
|
31
|
+
## 🚀 Features
|
|
32
|
+
|
|
33
|
+
✅ **Extensive Resource Coverage**: Scan a wide range of AWS services, including:
|
|
34
|
+
|
|
35
|
+
- **EC2**: Instances, EBS Volumes, EBS Snapshots, AMIs, Key Pairs, Launch Templates, Network Interfaces
|
|
36
|
+
- **RDS**: DB Instances, DB Subnet Groups, DB Parameter Groups
|
|
37
|
+
- **VPC**: VPCs, Subnets, Security Groups
|
|
38
|
+
- **IAM**: Roles and Policies
|
|
39
|
+
- **S3**: Buckets with Versioning and Public Access Block configurations
|
|
40
|
+
- **EIP**: Elastic IP Addresses
|
|
41
|
+
- **Load Balancing**: Application (ALB), Network (NLB), Gateway (GWLB), and Classic (CLB) Load Balancers, including Listeners and Target Groups
|
|
42
|
+
|
|
43
|
+
✅ **Automatic Dependency Scanning**: Start with a single resource (like an EC2 instance) and use the `--with-deps` flag to automatically find and scan all its dependencies.
|
|
44
|
+
|
|
45
|
+
✅ **Intelligent Code Generation**: Generates clean, formatted, and best-practice Terraform code (`.tf`) from your existing infrastructure.
|
|
46
|
+
|
|
47
|
+
✅ **Seamless Terraform Integration**:
|
|
48
|
+
- `terraback <service> import <id>` command provides a simple wrapper around `terraform import`
|
|
49
|
+
- `terraback <service> list` helps you find resource IDs needed for import
|
|
50
|
+
|
|
51
|
+
✅ **Helper Utilities**: Includes commands to list generated resources, analyse the output, and clean-all generated files to start fresh.
|
|
52
|
+
|
|
53
|
+
✅ **Flexible & Configurable**: Supports AWS profiles, regions, and custom output directories.
|
|
54
|
+
|
|
55
|
+
## 📦 Installation
|
|
56
|
+
|
|
57
|
+
It is highly recommended to install Terraback within a Python virtual environment.
|
|
58
|
+
|
|
59
|
+
**Clone the repository:**
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/bmoldo/terraback.git
|
|
62
|
+
cd terraback
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Create and activate a virtual environment:**
|
|
66
|
+
```bash
|
|
67
|
+
python -m venv .venv
|
|
68
|
+
|
|
69
|
+
# On Windows (PowerShell)
|
|
70
|
+
.\.venv\Scripts\Activate.ps1
|
|
71
|
+
|
|
72
|
+
# On Linux/macOS
|
|
73
|
+
source .venv/bin/activate
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Install Terraback in editable mode:**
|
|
77
|
+
```bash
|
|
78
|
+
pip install -e .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## ⚙️ Usage
|
|
82
|
+
|
|
83
|
+
Run `terraback --help` to see all available service commands. Run `terraback <service> --help` for details on a specific service.
|
|
84
|
+
|
|
85
|
+
### Global Options
|
|
86
|
+
|
|
87
|
+
- `--profile TEXT`: AWS CLI profile to use
|
|
88
|
+
- `--region TEXT`: AWS region (defaults to us-east-1)
|
|
89
|
+
- `--output-dir DIRECTORY` / `-o DIRECTORY`: Directory to save or read generated files (defaults to generated)
|
|
90
|
+
|
|
91
|
+
### General Commands
|
|
92
|
+
|
|
93
|
+
- `terraback analyse`: Shows a summary of all scanned resources
|
|
94
|
+
- `terraback list all`: Lists all resources from all `*_import.json` files in the output directory
|
|
95
|
+
- `terraback clean all`: Removes all generated `.tf` and `_import.json` files
|
|
96
|
+
|
|
97
|
+
### Service Commands
|
|
98
|
+
|
|
99
|
+
#### Load Balancers (`terraback elbv2 ...` and `terraback elb ...`)
|
|
100
|
+
- `terraback elbv2 scan-lbs`: Scans for modern Load Balancers (ALB, NLB, GWLB)
|
|
101
|
+
- `terraback elbv2 scan-tgs`: Scans for Target Groups
|
|
102
|
+
- `terraback elbv2 scan-listeners`: Scans for Listeners
|
|
103
|
+
- `terraback elb scan-classic`: Scans for Classic Load Balancers
|
|
104
|
+
|
|
105
|
+
...and corresponding `list-*` and `import-*` commands for each resource.
|
|
106
|
+
|
|
107
|
+
#### EC2 (`terraback ec2 ...`)
|
|
108
|
+
- `terraback ec2 scan`: Scans for EC2 Instances
|
|
109
|
+
- `--with-deps`: Automatically scans all dependencies (VPC, Subnet, SG, IAM Role, Volumes, LBs, etc.)
|
|
110
|
+
- `terraback ec2 scan-volumes`: Scans for EBS Volumes
|
|
111
|
+
|
|
112
|
+
...and many more.
|
|
113
|
+
|
|
114
|
+
#### RDS (`terraback rds ...`)
|
|
115
|
+
- `terraback rds scan-instances`: Scans for RDS DB Instances
|
|
116
|
+
- `terraback rds scan-subnet-groups`: Scans for RDS DB Subnet Groups
|
|
117
|
+
|
|
118
|
+
...and more.
|
|
119
|
+
|
|
120
|
+
*(For a full list of commands, run `terraback --help`)*
|
|
121
|
+
|
|
122
|
+
## 🎯 Dependency Scanning
|
|
123
|
+
|
|
124
|
+
Terraback's most powerful feature is automatic dependency discovery. When you scan an EC2 instance with `--with-deps`, it automatically finds and scans:
|
|
125
|
+
|
|
126
|
+
- **Networking**: VPC, Subnet, Security Groups, Network Interfaces, EIPs
|
|
127
|
+
- **Load Balancing**: ALBs, NLBs, CLBs, Target Groups, Listeners
|
|
128
|
+
- **Compute**: AMIs, Launch Templates, Key Pairs
|
|
129
|
+
- **Storage**: EBS Volumes and their Snapshots
|
|
130
|
+
- **Permissions**: IAM Roles
|
|
131
|
+
|
|
132
|
+
### Example Output
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
$ terraback ec2 scan --with-deps -o my-app
|
|
136
|
+
[RECURSIVE_SCAN] Calling scan for: ec2 with output_dir: my-app
|
|
137
|
+
Scanning for EC2 instances in region us-east-1...
|
|
138
|
+
Generated Terraform for 1 EC2 instances -> my-app\ec2.tf
|
|
139
|
+
...
|
|
140
|
+
[RECURSIVE_SCAN] Calling scan for: elbv2_target_group with output_dir: my-app
|
|
141
|
+
Scanning for Target Groups in region us-east-1...
|
|
142
|
+
Generated Terraform for 1 Target Groups -> my-app\elbv2_target_group.tf
|
|
143
|
+
...
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This creates a complete infrastructure snapshot with all dependencies automatically discovered!
|
|
147
|
+
|
|
148
|
+
## 🧭 What's Next (Roadmap)
|
|
149
|
+
|
|
150
|
+
- [x] ~~Add support for more AWS services~~ (RDS & Load Balancer Support Added!)
|
|
151
|
+
- 🔄 Expand dependency scanning to even more resources
|
|
152
|
+
- 🔗 Enhanced relationship mapping between resources
|
|
153
|
+
- 📝 Generate Terraform modules instead of flat configurations
|
|
154
|
+
- 🎨 Web UI for visualizing infrastructure dependencies
|
|
155
|
+
- ☁️ Support for other cloud providers (Azure, GCP)
|
|
156
|
+
|
|
157
|
+
## ⚖️ License
|
|
158
|
+
|
|
159
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Terraback
|
|
2
|
+
|
|
3
|
+
Terraback is a CLI tool that helps DevOps engineers generate Terraform code from existing AWS infrastructure with automatic dependency discovery.
|
|
4
|
+
|
|
5
|
+
**Automate Terraform adoption for legacy environments with zero guesswork.**
|
|
6
|
+
|
|
7
|
+
## 🚀 Features
|
|
8
|
+
|
|
9
|
+
✅ **Extensive Resource Coverage**: Scan a wide range of AWS services, including:
|
|
10
|
+
|
|
11
|
+
- **EC2**: Instances, EBS Volumes, EBS Snapshots, AMIs, Key Pairs, Launch Templates, Network Interfaces
|
|
12
|
+
- **RDS**: DB Instances, DB Subnet Groups, DB Parameter Groups
|
|
13
|
+
- **VPC**: VPCs, Subnets, Security Groups
|
|
14
|
+
- **IAM**: Roles and Policies
|
|
15
|
+
- **S3**: Buckets with Versioning and Public Access Block configurations
|
|
16
|
+
- **EIP**: Elastic IP Addresses
|
|
17
|
+
- **Load Balancing**: Application (ALB), Network (NLB), Gateway (GWLB), and Classic (CLB) Load Balancers, including Listeners and Target Groups
|
|
18
|
+
|
|
19
|
+
✅ **Automatic Dependency Scanning**: Start with a single resource (like an EC2 instance) and use the `--with-deps` flag to automatically find and scan all its dependencies.
|
|
20
|
+
|
|
21
|
+
✅ **Intelligent Code Generation**: Generates clean, formatted, and best-practice Terraform code (`.tf`) from your existing infrastructure.
|
|
22
|
+
|
|
23
|
+
✅ **Seamless Terraform Integration**:
|
|
24
|
+
- `terraback <service> import <id>` command provides a simple wrapper around `terraform import`
|
|
25
|
+
- `terraback <service> list` helps you find resource IDs needed for import
|
|
26
|
+
|
|
27
|
+
✅ **Helper Utilities**: Includes commands to list generated resources, analyse the output, and clean-all generated files to start fresh.
|
|
28
|
+
|
|
29
|
+
✅ **Flexible & Configurable**: Supports AWS profiles, regions, and custom output directories.
|
|
30
|
+
|
|
31
|
+
## 📦 Installation
|
|
32
|
+
|
|
33
|
+
It is highly recommended to install Terraback within a Python virtual environment.
|
|
34
|
+
|
|
35
|
+
**Clone the repository:**
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/bmoldo/terraback.git
|
|
38
|
+
cd terraback
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Create and activate a virtual environment:**
|
|
42
|
+
```bash
|
|
43
|
+
python -m venv .venv
|
|
44
|
+
|
|
45
|
+
# On Windows (PowerShell)
|
|
46
|
+
.\.venv\Scripts\Activate.ps1
|
|
47
|
+
|
|
48
|
+
# On Linux/macOS
|
|
49
|
+
source .venv/bin/activate
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Install Terraback in editable mode:**
|
|
53
|
+
```bash
|
|
54
|
+
pip install -e .
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## ⚙️ Usage
|
|
58
|
+
|
|
59
|
+
Run `terraback --help` to see all available service commands. Run `terraback <service> --help` for details on a specific service.
|
|
60
|
+
|
|
61
|
+
### Global Options
|
|
62
|
+
|
|
63
|
+
- `--profile TEXT`: AWS CLI profile to use
|
|
64
|
+
- `--region TEXT`: AWS region (defaults to us-east-1)
|
|
65
|
+
- `--output-dir DIRECTORY` / `-o DIRECTORY`: Directory to save or read generated files (defaults to generated)
|
|
66
|
+
|
|
67
|
+
### General Commands
|
|
68
|
+
|
|
69
|
+
- `terraback analyse`: Shows a summary of all scanned resources
|
|
70
|
+
- `terraback list all`: Lists all resources from all `*_import.json` files in the output directory
|
|
71
|
+
- `terraback clean all`: Removes all generated `.tf` and `_import.json` files
|
|
72
|
+
|
|
73
|
+
### Service Commands
|
|
74
|
+
|
|
75
|
+
#### Load Balancers (`terraback elbv2 ...` and `terraback elb ...`)
|
|
76
|
+
- `terraback elbv2 scan-lbs`: Scans for modern Load Balancers (ALB, NLB, GWLB)
|
|
77
|
+
- `terraback elbv2 scan-tgs`: Scans for Target Groups
|
|
78
|
+
- `terraback elbv2 scan-listeners`: Scans for Listeners
|
|
79
|
+
- `terraback elb scan-classic`: Scans for Classic Load Balancers
|
|
80
|
+
|
|
81
|
+
...and corresponding `list-*` and `import-*` commands for each resource.
|
|
82
|
+
|
|
83
|
+
#### EC2 (`terraback ec2 ...`)
|
|
84
|
+
- `terraback ec2 scan`: Scans for EC2 Instances
|
|
85
|
+
- `--with-deps`: Automatically scans all dependencies (VPC, Subnet, SG, IAM Role, Volumes, LBs, etc.)
|
|
86
|
+
- `terraback ec2 scan-volumes`: Scans for EBS Volumes
|
|
87
|
+
|
|
88
|
+
...and many more.
|
|
89
|
+
|
|
90
|
+
#### RDS (`terraback rds ...`)
|
|
91
|
+
- `terraback rds scan-instances`: Scans for RDS DB Instances
|
|
92
|
+
- `terraback rds scan-subnet-groups`: Scans for RDS DB Subnet Groups
|
|
93
|
+
|
|
94
|
+
...and more.
|
|
95
|
+
|
|
96
|
+
*(For a full list of commands, run `terraback --help`)*
|
|
97
|
+
|
|
98
|
+
## 🎯 Dependency Scanning
|
|
99
|
+
|
|
100
|
+
Terraback's most powerful feature is automatic dependency discovery. When you scan an EC2 instance with `--with-deps`, it automatically finds and scans:
|
|
101
|
+
|
|
102
|
+
- **Networking**: VPC, Subnet, Security Groups, Network Interfaces, EIPs
|
|
103
|
+
- **Load Balancing**: ALBs, NLBs, CLBs, Target Groups, Listeners
|
|
104
|
+
- **Compute**: AMIs, Launch Templates, Key Pairs
|
|
105
|
+
- **Storage**: EBS Volumes and their Snapshots
|
|
106
|
+
- **Permissions**: IAM Roles
|
|
107
|
+
|
|
108
|
+
### Example Output
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
$ terraback ec2 scan --with-deps -o my-app
|
|
112
|
+
[RECURSIVE_SCAN] Calling scan for: ec2 with output_dir: my-app
|
|
113
|
+
Scanning for EC2 instances in region us-east-1...
|
|
114
|
+
Generated Terraform for 1 EC2 instances -> my-app\ec2.tf
|
|
115
|
+
...
|
|
116
|
+
[RECURSIVE_SCAN] Calling scan for: elbv2_target_group with output_dir: my-app
|
|
117
|
+
Scanning for Target Groups in region us-east-1...
|
|
118
|
+
Generated Terraform for 1 Target Groups -> my-app\elbv2_target_group.tf
|
|
119
|
+
...
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
This creates a complete infrastructure snapshot with all dependencies automatically discovered!
|
|
123
|
+
|
|
124
|
+
## 🧭 What's Next (Roadmap)
|
|
125
|
+
|
|
126
|
+
- [x] ~~Add support for more AWS services~~ (RDS & Load Balancer Support Added!)
|
|
127
|
+
- 🔄 Expand dependency scanning to even more resources
|
|
128
|
+
- 🔗 Enhanced relationship mapping between resources
|
|
129
|
+
- 📝 Generate Terraform modules instead of flat configurations
|
|
130
|
+
- 🎨 Web UI for visualizing infrastructure dependencies
|
|
131
|
+
- ☁️ Support for other cloud providers (Azure, GCP)
|
|
132
|
+
|
|
133
|
+
## ⚖️ License
|
|
134
|
+
|
|
135
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import typer
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from .rest_apis import scan_rest_apis
|
|
4
|
+
|
|
5
|
+
from terraback.utils.cross_scan_registry import register_scan_function, cross_scan_registry
|
|
6
|
+
|
|
7
|
+
app = typer.Typer(
|
|
8
|
+
name="apigateway",
|
|
9
|
+
help="Manage API Gateway REST API resources.",
|
|
10
|
+
no_args_is_help=True
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
@app.command(name="scan-rest-apis", help="Scan REST APIs and all their sub-resources.")
|
|
14
|
+
def scan_apis_command(output_dir: Path = typer.Option("generated"), profile: str = typer.Option(None), region: str = typer.Option("us-east-1")):
|
|
15
|
+
scan_rest_apis(output_dir, profile, region)
|
|
16
|
+
|
|
17
|
+
# Note: list and import commands are omitted for now due to the complexity of nested resources.
|
|
18
|
+
|
|
19
|
+
def register():
|
|
20
|
+
"""Registers scan functions and dependencies for the API Gateway module."""
|
|
21
|
+
register_scan_function("api_gateway_rest_api", scan_rest_apis)
|
|
22
|
+
|
|
23
|
+
# Define dependencies
|
|
24
|
+
cross_scan_registry.register_dependency("api_gateway_integration", "lambda_function")
|
|
25
|
+
cross_scan_registry.register_dependency("lambda_function", "api_gateway_rest_api")
|