vpcrawler 0.1.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.
- vpcrawler-0.1.0/PKG-INFO +372 -0
- vpcrawler-0.1.0/README.md +360 -0
- vpcrawler-0.1.0/pyproject.toml +26 -0
- vpcrawler-0.1.0/setup.cfg +4 -0
- vpcrawler-0.1.0/src/aws_vpc_net_tester/__init__.py +3 -0
- vpcrawler-0.1.0/src/aws_vpc_net_tester/__main__.py +6 -0
- vpcrawler-0.1.0/src/aws_vpc_net_tester/cli.py +214 -0
- vpcrawler-0.1.0/src/aws_vpc_net_tester/config_validator.py +428 -0
- vpcrawler-0.1.0/src/aws_vpc_net_tester/models.py +114 -0
- vpcrawler-0.1.0/src/aws_vpc_net_tester/network_tester.py +173 -0
- vpcrawler-0.1.0/src/vpcrawler.egg-info/PKG-INFO +372 -0
- vpcrawler-0.1.0/src/vpcrawler.egg-info/SOURCES.txt +16 -0
- vpcrawler-0.1.0/src/vpcrawler.egg-info/dependency_links.txt +1 -0
- vpcrawler-0.1.0/src/vpcrawler.egg-info/entry_points.txt +2 -0
- vpcrawler-0.1.0/src/vpcrawler.egg-info/requires.txt +6 -0
- vpcrawler-0.1.0/src/vpcrawler.egg-info/top_level.txt +1 -0
- vpcrawler-0.1.0/tests/test_config_validator.py +112 -0
- vpcrawler-0.1.0/tests/test_network_tester.py +52 -0
vpcrawler-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vpcrawler
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A CLI tool to validate AWS VPC connectivity configuration between two VPCs
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: boto3>=1.28
|
|
8
|
+
Requires-Dist: typer>=0.9
|
|
9
|
+
Requires-Dist: rich>=13.0
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
12
|
+
|
|
13
|
+
# AWS VPC Networking Test Tool
|
|
14
|
+
|
|
15
|
+
A Python CLI tool that validates AWS VPC connectivity configuration between two VPCs and runs local network connectivity tests. Use it to troubleshoot cross-VPC connectivity, verify peering and Transit Gateway setup, and test reachability from your local machine to targets inside your VPCs.
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
The tool combines two capabilities:
|
|
20
|
+
|
|
21
|
+
1. **Configuration validation** — Uses the AWS API (boto3) to analyze route tables, security groups, network ACLs, VPC peering, and Transit Gateway attachments. It determines whether the *configuration* allows traffic to flow between two VPCs.
|
|
22
|
+
|
|
23
|
+
2. **Connectivity testing** — Runs ping, DNS resolution, and TCP port checks from your local machine to verify actual reachability. Targets can be specified manually or discovered automatically from EC2 instances in the VPCs.
|
|
24
|
+
|
|
25
|
+
All commands run from your local machine using your AWS profile. No agents or deployments inside AWS are required.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- **VPC configuration analysis** — CIDR overlap, route tables, security groups, NACLs, peering, Transit Gateway
|
|
30
|
+
- **IP range reporting** — VPC and subnet CIDR blocks with availability zones
|
|
31
|
+
- **Auto-discovery** — Find running EC2 instances in both VPCs and test them automatically
|
|
32
|
+
- **Local network tests** — Ping, DNS (dig/nslookup), TCP port checks
|
|
33
|
+
- **JSON output** — Machine-readable output for scripting and CI/CD
|
|
34
|
+
- **Cross-platform** — Works on macOS, Linux, and Windows
|
|
35
|
+
|
|
36
|
+
## Requirements
|
|
37
|
+
|
|
38
|
+
- Python 3.9+
|
|
39
|
+
- AWS credentials configured (profile or environment)
|
|
40
|
+
- Network access to AWS APIs and to targets you test (VPN, bastion, or direct if testing public endpoints)
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Clone or navigate to the project
|
|
46
|
+
cd vpcrawler
|
|
47
|
+
|
|
48
|
+
# Install in editable mode
|
|
49
|
+
pip install -e .
|
|
50
|
+
|
|
51
|
+
# Or install dependencies only
|
|
52
|
+
pip install -r requirements.txt
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Dependencies
|
|
56
|
+
|
|
57
|
+
- **boto3** — AWS SDK for Python
|
|
58
|
+
- **typer** — CLI framework
|
|
59
|
+
- **rich** — Formatted console output
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Validate configuration between two VPCs
|
|
65
|
+
vpcrawler --vpc-a vpc-0abc123 --vpc-b vpc-0def456 --profile myprofile
|
|
66
|
+
|
|
67
|
+
# Validate and automatically test EC2 instances in both VPCs
|
|
68
|
+
vpcrawler --vpc-a vpc-0abc123 --vpc-b vpc-0def456 --profile myprofile --auto-test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Usage Modes
|
|
72
|
+
|
|
73
|
+
### 1. Configuration Validation Only
|
|
74
|
+
|
|
75
|
+
Validates that the AWS configuration allows connectivity between two VPCs. No network tests are run.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
vpcrawler --vpc-a vpc-0abc123 --vpc-b vpc-0def456 --profile myprofile --region us-east-1
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use this to:
|
|
82
|
+
- Audit peering or Transit Gateway setup
|
|
83
|
+
- Verify route tables and security groups
|
|
84
|
+
- Check for CIDR overlap before peering
|
|
85
|
+
|
|
86
|
+
### 2. Auto-Test Mode
|
|
87
|
+
|
|
88
|
+
Discovers running EC2 instances in both VPCs and automatically runs ping and port checks against their private IPs.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
vpcrawler --vpc-a vpc-0abc123 --vpc-b vpc-0def456 --profile myprofile --auto-test
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
With options:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
vpcrawler --vpc-a vpc-0abc123 --vpc-b vpc-0def456 --auto-test \
|
|
98
|
+
--max-targets-per-vpc 3 \
|
|
99
|
+
--auto-test-ports 22,443,8080
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Note:** Auto-test requires your local machine to reach the EC2 private IPs (e.g., via VPN or bastion host). If you cannot reach private IPs from your machine, use manual targets instead.
|
|
103
|
+
|
|
104
|
+
### 3. Manual Connectivity Tests
|
|
105
|
+
|
|
106
|
+
Specify exact targets for ping, DNS, and port checks.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
vpcrawler --vpc-a vpc-0abc123 --vpc-b vpc-0def456 \
|
|
110
|
+
--ping 10.0.1.50 \
|
|
111
|
+
--dns internal.example.com \
|
|
112
|
+
--port 10.0.2.100:443
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
You can use any combination of `--ping`, `--port`, and `--dns`.
|
|
116
|
+
|
|
117
|
+
### 4. Combined Usage
|
|
118
|
+
|
|
119
|
+
Auto-test and manual targets can be used together. All tests run and appear in the output.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
vpcrawler --vpc-a vpc-0abc123 --vpc-b vpc-0def456 --auto-test \
|
|
123
|
+
--ping 10.0.1.1 \
|
|
124
|
+
--dns api.internal.example.com
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Command Reference
|
|
128
|
+
|
|
129
|
+
| Option | Required | Default | Description |
|
|
130
|
+
|--------|----------|---------|-------------|
|
|
131
|
+
| `--vpc-a` | Yes | — | First VPC ID |
|
|
132
|
+
| `--vpc-b` | Yes | — | Second VPC ID |
|
|
133
|
+
| `--profile` | No | `AWS_PROFILE` env | AWS profile name |
|
|
134
|
+
| `--region` | No | `us-east-1` | AWS region |
|
|
135
|
+
| `--auto-test` | No | `false` | Discover EC2 instances and run ping/port checks |
|
|
136
|
+
| `--max-targets-per-vpc` | No | `5` | Max instances to test per VPC with `--auto-test` |
|
|
137
|
+
| `--auto-test-ports` | No | `22,443` | Ports to check with `--auto-test` (comma-separated) |
|
|
138
|
+
| `--ping` | No | — | IP or hostname to ping |
|
|
139
|
+
| `--dns` | No | — | Hostname to resolve via DNS |
|
|
140
|
+
| `--port` | No | — | `host:port` to test (e.g., `10.0.2.100:443`) |
|
|
141
|
+
| `--json` | No | `false` | Output results as JSON |
|
|
142
|
+
|
|
143
|
+
## Configuration Validation
|
|
144
|
+
|
|
145
|
+
The tool runs these checks to determine if connectivity *should* work between the two VPCs:
|
|
146
|
+
|
|
147
|
+
### CIDR Overlap
|
|
148
|
+
|
|
149
|
+
VPC peering and Transit Gateway require non-overlapping CIDR blocks. If the VPCs overlap, peering cannot be established.
|
|
150
|
+
|
|
151
|
+
- **PASS** — CIDRs do not overlap
|
|
152
|
+
- **FAIL** — CIDRs overlap; connectivity not possible
|
|
153
|
+
|
|
154
|
+
### VPC Peering
|
|
155
|
+
|
|
156
|
+
Checks for an active VPC peering connection between the two VPCs.
|
|
157
|
+
|
|
158
|
+
- **PASS** — Active peering exists
|
|
159
|
+
- **FAIL** — No peering (and no Transit Gateway fallback)
|
|
160
|
+
|
|
161
|
+
### Transit Gateway
|
|
162
|
+
|
|
163
|
+
If no peering exists, checks whether both VPCs are attached to the same Transit Gateway.
|
|
164
|
+
|
|
165
|
+
- **PASS** — Both VPCs attached to same TGW
|
|
166
|
+
- **FAIL** — No shared Transit Gateway
|
|
167
|
+
|
|
168
|
+
### Route Tables
|
|
169
|
+
|
|
170
|
+
When peering or TGW exists, verifies that route tables in both VPCs have routes for the peer VPC’s CIDR.
|
|
171
|
+
|
|
172
|
+
- **PASS** — Routes exist in both directions
|
|
173
|
+
- **FAIL** — Missing routes in one or both VPCs
|
|
174
|
+
|
|
175
|
+
### Security Groups
|
|
176
|
+
|
|
177
|
+
Checks whether any security groups allow traffic between the VPC CIDRs (ingress and egress).
|
|
178
|
+
|
|
179
|
+
- **PASS** — Rules allow cross-VPC traffic
|
|
180
|
+
- **WARN** — May restrict traffic; manual verification recommended
|
|
181
|
+
|
|
182
|
+
### Network ACLs
|
|
183
|
+
|
|
184
|
+
Looks for NACL deny rules that could block cross-VPC traffic.
|
|
185
|
+
|
|
186
|
+
- **PASS** — No blocking rules found
|
|
187
|
+
- **WARN** — Deny rules may block traffic; manual verification recommended
|
|
188
|
+
|
|
189
|
+
### Connectivity Path
|
|
190
|
+
|
|
191
|
+
Overall result: **VALID** if no checks fail, **INVALID** if any check fails.
|
|
192
|
+
|
|
193
|
+
## Local Connectivity Tests
|
|
194
|
+
|
|
195
|
+
Tests run from your local machine. Your machine must have network path to the targets (VPN, bastion, or direct access).
|
|
196
|
+
|
|
197
|
+
### Ping
|
|
198
|
+
|
|
199
|
+
- **Command:** `ping -c 4` (Linux/macOS) or `ping -n 4` (Windows)
|
|
200
|
+
- **Purpose:** ICMP reachability
|
|
201
|
+
- **Timeout:** 15 seconds
|
|
202
|
+
|
|
203
|
+
### DNS
|
|
204
|
+
|
|
205
|
+
- **Command:** `dig +short` (preferred) or `nslookup`
|
|
206
|
+
- **Purpose:** Hostname resolution
|
|
207
|
+
- **Timeout:** 10 seconds
|
|
208
|
+
- **Note:** Requires `dig` or `nslookup` on your system
|
|
209
|
+
|
|
210
|
+
### Port Check
|
|
211
|
+
|
|
212
|
+
- **Command:** `nc -zv` (netcat) or Python socket fallback
|
|
213
|
+
- **Purpose:** TCP connectivity
|
|
214
|
+
- **Timeout:** 5 seconds
|
|
215
|
+
- **Note:** Uses `nc` when available; otherwise uses a built-in socket check
|
|
216
|
+
|
|
217
|
+
## Output
|
|
218
|
+
|
|
219
|
+
### Console Output
|
|
220
|
+
|
|
221
|
+
- **VPC Configuration** — VPC IDs, CIDR blocks, region
|
|
222
|
+
- **IP Ranges** — VPC and subnet CIDRs with availability zones
|
|
223
|
+
- **Validation Checks** — Table of checks with PASS/FAIL/WARN
|
|
224
|
+
- **Connectivity Path** — Overall VALID or INVALID
|
|
225
|
+
- **Local Network Tests** — Table of ping, DNS, and port results
|
|
226
|
+
|
|
227
|
+
Failed network tests include the raw command output for debugging.
|
|
228
|
+
|
|
229
|
+
### JSON Output
|
|
230
|
+
|
|
231
|
+
Use `--json` for machine-readable output:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
vpcrawler --vpc-a vpc-0abc123 --vpc-b vpc-0def456 --json
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Structure:
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"config": {
|
|
242
|
+
"vpc_a": { "vpc_id": "...", "cidr_block": "...", "subnets": [...] },
|
|
243
|
+
"vpc_b": { "vpc_id": "...", "cidr_block": "...", "subnets": [...] },
|
|
244
|
+
"checks": [{ "name": "...", "status": "pass|fail|warn", "message": "..." }],
|
|
245
|
+
"connectivity_path_valid": true,
|
|
246
|
+
"error": null
|
|
247
|
+
},
|
|
248
|
+
"network_tests": [
|
|
249
|
+
{ "test_type": "ping", "target": "...", "status": "pass", "message": "...", "duration_ms": 123 }
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## AWS Permissions
|
|
255
|
+
|
|
256
|
+
The tool uses these EC2 API operations:
|
|
257
|
+
|
|
258
|
+
- `DescribeVpcs`
|
|
259
|
+
- `DescribeSubnets`
|
|
260
|
+
- `DescribeRouteTables`
|
|
261
|
+
- `DescribeSecurityGroups`
|
|
262
|
+
- `DescribeNetworkAcls`
|
|
263
|
+
- `DescribeVpcPeeringConnections`
|
|
264
|
+
- `DescribeTransitGatewayAttachments`
|
|
265
|
+
- `DescribeInstances` (when using `--auto-test`)
|
|
266
|
+
|
|
267
|
+
A minimal IAM policy:
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"Version": "2012-10-17",
|
|
272
|
+
"Statement": [
|
|
273
|
+
{
|
|
274
|
+
"Effect": "Allow",
|
|
275
|
+
"Action": [
|
|
276
|
+
"ec2:DescribeVpcs",
|
|
277
|
+
"ec2:DescribeSubnets",
|
|
278
|
+
"ec2:DescribeRouteTables",
|
|
279
|
+
"ec2:DescribeSecurityGroups",
|
|
280
|
+
"ec2:DescribeNetworkAcls",
|
|
281
|
+
"ec2:DescribeVpcPeeringConnections",
|
|
282
|
+
"ec2:DescribeTransitGatewayAttachments",
|
|
283
|
+
"ec2:DescribeInstances"
|
|
284
|
+
],
|
|
285
|
+
"Resource": "*"
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Troubleshooting
|
|
292
|
+
|
|
293
|
+
### "VPC(s) not found"
|
|
294
|
+
|
|
295
|
+
- Confirm VPC IDs are correct
|
|
296
|
+
- Ensure `--region` matches the VPCs
|
|
297
|
+
- Verify AWS credentials and profile
|
|
298
|
+
|
|
299
|
+
### "No active VPC peering or Transit Gateway connection"
|
|
300
|
+
|
|
301
|
+
- Check that peering is in `active` state
|
|
302
|
+
- For Transit Gateway, ensure both VPCs are attached to the same TGW
|
|
303
|
+
|
|
304
|
+
### Ping/port checks fail from local machine
|
|
305
|
+
|
|
306
|
+
- Private IPs are only reachable from within the VPC or via VPN/bastion
|
|
307
|
+
- Ensure your machine has a path to the target (VPN, SSH tunnel, etc.)
|
|
308
|
+
- Firewall or security groups may block ICMP or the tested ports
|
|
309
|
+
|
|
310
|
+
### DNS resolution fails
|
|
311
|
+
|
|
312
|
+
- `dig` or `nslookup` must be installed
|
|
313
|
+
- Private hostnames require DNS resolution that can reach your private zones (e.g., Route 53 Resolver, VPN split-tunnel DNS)
|
|
314
|
+
|
|
315
|
+
## Limitations
|
|
316
|
+
|
|
317
|
+
- **Single region** — Both VPCs must be in the same region (cross-region peering not yet supported)
|
|
318
|
+
- **Local tests** — Connectivity tests run from your machine; they do not test traffic between instances inside the VPCs
|
|
319
|
+
- **Private IPs** — Auto-test uses private IPs; your machine must be able to reach them (VPN, etc.)
|
|
320
|
+
|
|
321
|
+
## Development
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
# Install with dev dependencies
|
|
325
|
+
pip install -e ".[dev]"
|
|
326
|
+
|
|
327
|
+
# Run tests
|
|
328
|
+
pytest tests/ -v
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Project Structure
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
vpcrawler/
|
|
335
|
+
├── src/aws_vpc_net_tester/
|
|
336
|
+
│ ├── cli.py # CLI entry point
|
|
337
|
+
│ ├── config_validator.py # boto3 VPC analysis + EC2 discovery
|
|
338
|
+
│ ├── models.py # Data classes
|
|
339
|
+
│ └── network_tester.py # Ping, DNS, port checks
|
|
340
|
+
├── tests/
|
|
341
|
+
├── pyproject.toml
|
|
342
|
+
└── requirements.txt
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Publishing to PyPI
|
|
346
|
+
|
|
347
|
+
Releases are published automatically via [GitHub Actions](https://github.com/marketplace/actions/pypi-publish) when you push a version tag.
|
|
348
|
+
|
|
349
|
+
### Setup (one-time)
|
|
350
|
+
|
|
351
|
+
1. **Create a PyPI project** — Register `vpcrawler` on [pypi.org](https://pypi.org) if it does not exist.
|
|
352
|
+
|
|
353
|
+
2. **Configure trusted publishing** — In your PyPI project settings, add a trusted publisher:
|
|
354
|
+
- Publisher: GitHub Actions
|
|
355
|
+
- Owner: your GitHub org/username
|
|
356
|
+
- Repository: your repo name
|
|
357
|
+
- Workflow: `publish.yml`
|
|
358
|
+
- Environment: `pypi`
|
|
359
|
+
|
|
360
|
+
3. **Create the `pypi` environment** — In your GitHub repo: Settings → Environments → New environment → name it `pypi`.
|
|
361
|
+
|
|
362
|
+
### Releasing
|
|
363
|
+
|
|
364
|
+
1. Update the version in `pyproject.toml`.
|
|
365
|
+
2. Commit, then create and push a tag:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
git tag v0.1.0
|
|
369
|
+
git push origin v0.1.0
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
3. The workflow builds the package and publishes to PyPI. No API tokens are required when using trusted publishing.
|