aws-resource-inventory 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.
- aws_resource_inventory-0.1.0/LICENSE +21 -0
- aws_resource_inventory-0.1.0/PKG-INFO +557 -0
- aws_resource_inventory-0.1.0/README.md +524 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/__init__.py +8 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/cache.py +124 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/clients.py +42 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/engine.py +189 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/logging.py +492 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/outputs.py +282 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/records.py +46 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/resource_groups_utils.py +309 -0
- aws_resource_inventory-0.1.0/aws_scanner_lib/scan.py +274 -0
- aws_resource_inventory-0.1.0/pyproject.toml +172 -0
- aws_resource_inventory-0.1.0/services/__init__.py +8 -0
- aws_resource_inventory-0.1.0/services/autoscaling_service.py +140 -0
- aws_resource_inventory-0.1.0/services/ec2_service.py +138 -0
- aws_resource_inventory-0.1.0/services/ecs_service.py +210 -0
- aws_resource_inventory-0.1.0/services/efs_service.py +49 -0
- aws_resource_inventory-0.1.0/services/elb_service.py +184 -0
- aws_resource_inventory-0.1.0/services/rds_service.py +98 -0
- aws_resource_inventory-0.1.0/services/registry.py +58 -0
- aws_resource_inventory-0.1.0/services/s3_service.py +88 -0
- aws_resource_inventory-0.1.0/services/vpc_service.py +162 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ishan Sharma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aws-resource-inventory
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AWS multi-service resource inventory with tag-based filtering and advanced optimizations
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: aws,scanner,cloud,infrastructure,devops
|
|
8
|
+
Author: Ishan Sharma
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: System Administrators
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: System :: Systems Administration
|
|
19
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Dist: boto3 (>=1.40.34)
|
|
22
|
+
Requires-Dist: botocore (>=1.40.34)
|
|
23
|
+
Requires-Dist: click (>=8.3.0)
|
|
24
|
+
Requires-Dist: pyfiglet (>=1.0.4)
|
|
25
|
+
Requires-Dist: rich (>=14.1.0)
|
|
26
|
+
Requires-Dist: setuptools (>=80.9.0)
|
|
27
|
+
Requires-Dist: typer (>=0.17.4)
|
|
28
|
+
Requires-Dist: urllib3 (>=2.5.0)
|
|
29
|
+
Project-URL: Homepage, https://github.com/ishuar/aws-resource-inventory
|
|
30
|
+
Project-URL: Repository, https://github.com/ishuar/aws-resource-inventory
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# AWS Resource Inventory
|
|
34
|
+
|
|
35
|
+
[](https://opensource.org/licenses/MIT)
|
|
36
|
+
[](https://www.python.org/downloads/)
|
|
37
|
+
[](https://github.com/psf/black)
|
|
38
|
+
[](https://results.pre-commit.ci/latest/github/ishuar/aws-resource-inventory/main)
|
|
39
|
+
|
|
40
|
+
A comprehensive AWS multi-service scanner with tag-based filtering, parallel processing, advanced logging capabilities, and optimization features. This tool enables efficient discovery and analysis of AWS resources across multiple regions and services with intelligent caching, rich output formats, and detailed AWS API tracing.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- Scans eight AWS services โ EC2, S3, ECS, EFS, VPC, RDS, ELB, and Auto Scaling โ across multiple regions concurrently, with or without tag filters.
|
|
45
|
+
- Discovers resources from 100+ AWS services via the Resource Groups Tagging API (`--all-services`, requires a tag filter).
|
|
46
|
+
- Table, JSON, and Markdown output; results are rendered in the terminal and written to a file for further processing.
|
|
47
|
+
- Result caching with a 10-minute TTL (`--cache` / `--no-cache`).
|
|
48
|
+
- Configurable parallelism per region (`--max-workers`) and per service (`--service-workers`), dry-run preview, continuous refresh mode, and graceful Ctrl+C handling.
|
|
49
|
+
- Debug traces (`--debug`), full AWS API tracing (`--verbose`), and custom log files (`--log-file`) โ see [Logging Architecture](docs/LOGGING_ARCHITECTURE.md).
|
|
50
|
+
|
|
51
|
+
## ๐๏ธ Supported AWS Services
|
|
52
|
+
|
|
53
|
+
| Service | Description | Resources Scanned |
|
|
54
|
+
|------------------|-------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
|
|
55
|
+
| **All Services** | With [Resource Groups Tagging API](https://docs.aws.amazon.com/resourcegroupstagging/latest/APIReference/overview.html) | 100+ AWS services when using tags |
|
|
56
|
+
| **EC2** | Elastic Compute Cloud | Instances, Volumes, Security Groups, AMIs, Snapshots |
|
|
57
|
+
| **S3** | Simple Storage Service | Buckets and their configurations |
|
|
58
|
+
| **ECS** | Elastic Container Service | Clusters, Services, Task Definitions, Capacity Providers |
|
|
59
|
+
| **VPC** | Virtual Private Cloud | VPCs, Subnets, Route Tables, IGWs, NAT Gateways, DHCP Options, Peering Connections, Endpoints |
|
|
60
|
+
| **Auto Scaling** | Auto Scaling Groups | ASGs, Launch Configurations, Launch Templates |
|
|
61
|
+
| **ELB** | Elastic Load Balancing | Load Balancers (ALB/NLB), Target Groups, Listeners, Listener Rules |
|
|
62
|
+
| **RDS** | Relational Database Service | DB Instances, DB Clusters, DB Snapshots, Aurora Cluster Snapshots |
|
|
63
|
+
| **EFS** | Elastic File System | File Systems (with size and mount-target details) |
|
|
64
|
+
|
|
65
|
+
> **๐ Architecture Details**: For detailed information about the scanning architecture and service implementation patterns, see [Architecture Documentation](docs/Architecture.md).
|
|
66
|
+
|
|
67
|
+
## ๐ Prerequisites
|
|
68
|
+
|
|
69
|
+
Before installing the AWS Resource Inventory, ensure you have the following dependencies:
|
|
70
|
+
|
|
71
|
+
### Required Software
|
|
72
|
+
- **Python 3.10+** - Runtime environment
|
|
73
|
+
- **Poetry** - Python dependency management and packaging
|
|
74
|
+
- **pip** - Python package installer
|
|
75
|
+
- **AWS CLI** - AWS command line interface for authentication
|
|
76
|
+
- **pre-commit** - Git hooks framework (for development)
|
|
77
|
+
|
|
78
|
+
### AWS Configuration
|
|
79
|
+
- Valid AWS credentials configured via:
|
|
80
|
+
- AWS SSO (`aws sso login`)
|
|
81
|
+
- AWS CLI (`aws configure`)
|
|
82
|
+
- Environment variables
|
|
83
|
+
- IAM roles (for EC2/containers)
|
|
84
|
+
|
|
85
|
+
### Required IAM Permissions
|
|
86
|
+
|
|
87
|
+
The scanner is read-only. This policy covers every API call it makes โ
|
|
88
|
+
the eight service scanners, the credential check (`sts`), and the tag
|
|
89
|
+
scan (`tag:GetResources`, only exercised with `--tag-key`/`--tag-value`/
|
|
90
|
+
`--all-services`):
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"Version": "2012-10-17",
|
|
95
|
+
"Statement": [
|
|
96
|
+
{
|
|
97
|
+
"Sid": "AwsResourceInventoryReadOnly",
|
|
98
|
+
"Effect": "Allow",
|
|
99
|
+
"Action": [
|
|
100
|
+
"sts:GetCallerIdentity",
|
|
101
|
+
"ec2:Describe*",
|
|
102
|
+
"s3:ListAllMyBuckets",
|
|
103
|
+
"s3:GetBucketLocation",
|
|
104
|
+
"s3:GetBucketTagging",
|
|
105
|
+
"ecs:List*",
|
|
106
|
+
"ecs:Describe*",
|
|
107
|
+
"elasticloadbalancing:Describe*",
|
|
108
|
+
"elasticfilesystem:Describe*",
|
|
109
|
+
"rds:Describe*",
|
|
110
|
+
"autoscaling:Describe*",
|
|
111
|
+
"tag:GetResources"
|
|
112
|
+
],
|
|
113
|
+
"Resource": "*"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
> [!NOTE]
|
|
120
|
+
> `ec2:Describe*` also covers the VPC scanner and Auto Scaling launch
|
|
121
|
+
> templates โ both use the EC2 API. The AWS-managed `ReadOnlyAccess`
|
|
122
|
+
> policy works too if you prefer not to maintain a custom one.
|
|
123
|
+
|
|
124
|
+
## ๐ **Installation**
|
|
125
|
+
|
|
126
|
+
### Automated Setup (Recommended)
|
|
127
|
+
|
|
128
|
+
The easiest way to get started is using our automated setup script:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Clone the repository
|
|
132
|
+
git clone https://github.com/ishuar/aws-resource-inventory.git
|
|
133
|
+
cd aws-resource-inventory
|
|
134
|
+
|
|
135
|
+
# Run the automated setup script
|
|
136
|
+
./setup.sh
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The setup script will:
|
|
140
|
+
1. โ
Check and install Python 3.10+
|
|
141
|
+
2. โ
Install Poetry (Python dependency manager)
|
|
142
|
+
3. โ
Install pre-commit (Git hooks framework)
|
|
143
|
+
4. โ
Set up pre-commit hooks
|
|
144
|
+
5. โ
Install all project dependencies via Poetry
|
|
145
|
+
6. โ
Run verification tests
|
|
146
|
+
7. โ
Install AWS CLI (if not present)
|
|
147
|
+
8. โ
Provide AWS configuration guidance
|
|
148
|
+
|
|
149
|
+
> [!Tip]
|
|
150
|
+
> For detailed setup instructions and troubleshooting, see [setup.sh](setup.sh).
|
|
151
|
+
|
|
152
|
+
### Manual Installation
|
|
153
|
+
|
|
154
|
+
If you prefer manual installation:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Install dependencies (macOS with Homebrew)
|
|
158
|
+
brew install python3 poetry pre-commit awscli
|
|
159
|
+
|
|
160
|
+
# Install project dependencies
|
|
161
|
+
poetry install
|
|
162
|
+
|
|
163
|
+
# Set up pre-commit hooks
|
|
164
|
+
pre-commit install --install-hooks
|
|
165
|
+
|
|
166
|
+
# Verify installation
|
|
167
|
+
./run_quick_tests.sh
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## ๐ป Usage
|
|
171
|
+
|
|
172
|
+
### Command Structure
|
|
173
|
+
|
|
174
|
+
All commands follow this pattern:
|
|
175
|
+
```bash
|
|
176
|
+
poetry run aws-inventory [GLOBAL OPTIONS] COMMAND [COMMAND OPTIONS]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Global options apply to all commands: `--verbose` / `-v` (AWS API tracing,
|
|
180
|
+
use with `--debug`) and `--log-file` / `-l` (custom log file path). The
|
|
181
|
+
main command is `scan`.
|
|
182
|
+
|
|
183
|
+
> [!IMPORTANT]
|
|
184
|
+
> Global options must come **before** the command. `aws-inventory scan --verbose`
|
|
185
|
+
> fails with `No such option: --verbose` โ the correct form is
|
|
186
|
+
> `aws-inventory --verbose scan`.
|
|
187
|
+
|
|
188
|
+
### Basic Commands
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Display help and available commands
|
|
192
|
+
poetry run aws-inventory --help
|
|
193
|
+
|
|
194
|
+
# Display scan command help and options
|
|
195
|
+
poetry run aws-inventory scan --help
|
|
196
|
+
|
|
197
|
+
# Basic scan with default settings (all supported services)
|
|
198
|
+
poetry run aws-inventory scan --regions us-east-1,eu-west-1,eu-central-1,us-west-2
|
|
199
|
+
|
|
200
|
+
# Scan specific services
|
|
201
|
+
poetry run aws-inventory scan --service ec2
|
|
202
|
+
|
|
203
|
+
# Scan specific regions
|
|
204
|
+
poetry run aws-inventory scan --regions us-east-1,eu-west-1
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Debug and Logging Options
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Enable debug mode for detailed execution traces
|
|
211
|
+
poetry run aws-inventory scan --debug --regions us-east-1
|
|
212
|
+
|
|
213
|
+
# Enable verbose AWS API tracing (requires --debug)
|
|
214
|
+
poetry run aws-inventory --verbose scan --debug --service ec2
|
|
215
|
+
|
|
216
|
+
# Custom log file for debug output
|
|
217
|
+
poetry run aws-inventory --log-file /tmp/my-scan.log scan --debug --regions us-east-1
|
|
218
|
+
|
|
219
|
+
# Combine verbose logging with custom log file
|
|
220
|
+
poetry run aws-inventory --verbose --log-file /tmp/aws-api-trace.log scan --debug --service ec2 --service s3
|
|
221
|
+
|
|
222
|
+
# Debug with dry run (no actual scanning)
|
|
223
|
+
poetry run aws-inventory --verbose scan --debug --dry-run --service vpc
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Service-Specific Scanning
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Scan only EC2 resources
|
|
230
|
+
poetry run aws-inventory scan --service ec2
|
|
231
|
+
|
|
232
|
+
# Scan multiple services
|
|
233
|
+
poetry run aws-inventory scan --service ec2 --service s3 --service vpc
|
|
234
|
+
|
|
235
|
+
# Scan all built-in services in specific regions
|
|
236
|
+
poetry run aws-inventory scan --regions us-east-1,us-west-2
|
|
237
|
+
|
|
238
|
+
# Combine service and region filtering
|
|
239
|
+
poetry run aws-inventory scan --service ec2 --regions eu-central-1,eu-west-1
|
|
240
|
+
|
|
241
|
+
# Scan ALL AWS services using Resource Groups API (requires tags)
|
|
242
|
+
poetry run aws-inventory scan --all-services --tag-key Environment --tag-value Production
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Tag-Based Filtering
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Filter by environment tag
|
|
249
|
+
poetry run aws-inventory scan --tag-key Environment --tag-value Production
|
|
250
|
+
|
|
251
|
+
# Filter by application tag
|
|
252
|
+
poetry run aws-inventory scan --tag-key app --tag-value web-server
|
|
253
|
+
|
|
254
|
+
# Filter by cost center in specific regions
|
|
255
|
+
poetry run aws-inventory scan --regions us-east-1 --tag-key CostCenter --tag-value Engineering
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Output Formats
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Default table format (human-readable)
|
|
262
|
+
poetry run aws-inventory scan --format table
|
|
263
|
+
|
|
264
|
+
# JSON format for programmatic processing
|
|
265
|
+
poetry run aws-inventory scan --format json --output results.json
|
|
266
|
+
|
|
267
|
+
# Markdown format for documentation
|
|
268
|
+
poetry run aws-inventory scan --format md --output report.md
|
|
269
|
+
|
|
270
|
+
# Export filtered results to JSON
|
|
271
|
+
poetry run aws-inventory scan --tag-key Environment --tag-value Production --format json --output prod-resources.json
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Advanced Options
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Dry run (preview without execution)
|
|
278
|
+
poetry run aws-inventory scan --dry-run --service ec2
|
|
279
|
+
|
|
280
|
+
# Disable caching for fresh data
|
|
281
|
+
poetry run aws-inventory scan --no-cache
|
|
282
|
+
|
|
283
|
+
# Configure worker threads for performance
|
|
284
|
+
poetry run aws-inventory scan --max-workers 10 --service-workers 6
|
|
285
|
+
|
|
286
|
+
# Continuous refresh mode with custom interval
|
|
287
|
+
poetry run aws-inventory scan --refresh --refresh-interval 30 --service ec2
|
|
288
|
+
|
|
289
|
+
# Debug mode with performance timing
|
|
290
|
+
poetry run aws-inventory --verbose scan --debug --max-workers 1 --service ec2
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Real-World Examples
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Production infrastructure audit with comprehensive logging
|
|
297
|
+
poetry run aws-inventory --verbose --log-file prod-audit.log scan \
|
|
298
|
+
--debug --tag-key Environment --tag-value Production \
|
|
299
|
+
--format json --output production-audit.json
|
|
300
|
+
|
|
301
|
+
# Regional compliance check with detailed tracing
|
|
302
|
+
poetry run aws-inventory --verbose --log-file compliance-trace.log scan \
|
|
303
|
+
--debug --regions eu-west-1,eu-central-1 \
|
|
304
|
+
--service ec2 --format md --output eu-compliance-report.md
|
|
305
|
+
|
|
306
|
+
# Application-specific resource discovery across all AWS services
|
|
307
|
+
poetry run aws-inventory scan \
|
|
308
|
+
--all-services --tag-key Application --tag-value MyApp \
|
|
309
|
+
--format table --regions us-east-1
|
|
310
|
+
|
|
311
|
+
# Development environment troubleshooting with verbose logging
|
|
312
|
+
poetry run aws-inventory --verbose --log-file dev-debug.log scan \
|
|
313
|
+
--debug --regions us-west-2 \
|
|
314
|
+
--tag-key Environment --tag-value Development \
|
|
315
|
+
--no-cache --dry-run
|
|
316
|
+
|
|
317
|
+
# Performance analysis with sequential processing
|
|
318
|
+
poetry run aws-inventory --verbose --log-file perf-analysis.log scan \
|
|
319
|
+
--debug --max-workers 1 --service-workers 1 \
|
|
320
|
+
--service ec2 --service s3 --regions us-east-1
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## ๐ง Configuration
|
|
324
|
+
|
|
325
|
+
### AWS Profile Configuration
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
# Set AWS profile
|
|
329
|
+
export AWS_PROFILE=your-profile-name
|
|
330
|
+
|
|
331
|
+
# Login via SSO
|
|
332
|
+
aws sso login --profile $AWS_PROFILE
|
|
333
|
+
|
|
334
|
+
# Verify credentials
|
|
335
|
+
aws sts get-caller-identity
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Logging Configuration
|
|
339
|
+
|
|
340
|
+
The scanner features a comprehensive logging system with multiple configuration options:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
# Global logging options (apply to all commands)
|
|
344
|
+
poetry run aws-inventory --verbose --log-file /path/to/logfile.log scan --debug
|
|
345
|
+
|
|
346
|
+
# Debug modes explained:
|
|
347
|
+
# --debug: Enable debug mode with rich console output and file logging
|
|
348
|
+
# --verbose: Enable AWS API tracing (requires --debug)
|
|
349
|
+
# --log-file: Custom log file path (default: .debug_logs/aws_scanner_debug_TIMESTAMP.log)
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Logging levels: normal runs show progress and results; `--debug` adds
|
|
353
|
+
execution traces, timing, and caller context; `--verbose` together with
|
|
354
|
+
`--debug` adds full AWS API tracing including HTTP requests and responses.
|
|
355
|
+
|
|
356
|
+
> [!Tip]
|
|
357
|
+
> **๐ Detailed Logging Guide**: For comprehensive logging documentation, configuration examples, and troubleshooting, see [Logging Architecture](docs/LOGGING_ARCHITECTURE.md).
|
|
358
|
+
|
|
359
|
+
### Performance Tuning
|
|
360
|
+
|
|
361
|
+
- `--max-workers` (1-20) controls region-level parallelism; `--service-workers` (1-10) controls service-level parallelism.
|
|
362
|
+
- `--cache` speeds up repeated scans (10-minute TTL); `--no-cache` forces fresh data.
|
|
363
|
+
|
|
364
|
+
> [!NOTE]
|
|
365
|
+
> Verbose logging adds roughly 10-20% overhead โ use it for troubleshooting, not routine scans.
|
|
366
|
+
|
|
367
|
+
## ๐ **Project Structure**
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
aws-resource-inventory/
|
|
371
|
+
โโโ aws_scanner.py # Scan orchestration across regions
|
|
372
|
+
โโโ cli.py # Command-line interface (typer)
|
|
373
|
+
โโโ setup.sh # Automated setup script
|
|
374
|
+
โโโ run_quick_tests.sh # Smoke-test script
|
|
375
|
+
โโโ pyproject.toml # Project configuration and dependencies
|
|
376
|
+
โ
|
|
377
|
+
โโโ services/ # One scanner module per AWS service
|
|
378
|
+
โ โโโ registry.py # Single source of truth: service โ scanner + output processor
|
|
379
|
+
โ โโโ ec2_service.py # Instances, volumes, security groups, AMIs, snapshots
|
|
380
|
+
โ โโโ s3_service.py # Buckets (region-filtered, tag-enriched)
|
|
381
|
+
โ โโโ ecs_service.py # Clusters, services, task definitions, capacity providers
|
|
382
|
+
โ โโโ efs_service.py # File systems
|
|
383
|
+
โ โโโ elb_service.py # Load balancers, target groups, listeners, rules
|
|
384
|
+
โ โโโ rds_service.py # DB instances, clusters, snapshots (incl. Aurora)
|
|
385
|
+
โ โโโ vpc_service.py # VPC networking components
|
|
386
|
+
โ โโโ autoscaling_service.py # ASGs, launch configurations, launch templates
|
|
387
|
+
โ
|
|
388
|
+
โโโ aws_scanner_lib/ # Core library modules
|
|
389
|
+
โ โโโ engine.py # Shared scanning engine: pagination, concurrency, error policy
|
|
390
|
+
โ โโโ records.py # Resource โ the typed record every output consumes
|
|
391
|
+
โ โโโ clients.py # The only boto3 client factory (pooling, adaptive retries)
|
|
392
|
+
โ โโโ scan.py # Region/service scan orchestration + caching hooks
|
|
393
|
+
โ โโโ outputs.py # Table / JSON / Markdown output processing
|
|
394
|
+
โ โโโ resource_groups_utils.py # Resource Groups Tagging API path (--all-services, tags)
|
|
395
|
+
โ โโโ cache.py # Result caching with TTL
|
|
396
|
+
โ โโโ logging.py # Unified logging with AWS API tracing
|
|
397
|
+
โ
|
|
398
|
+
โโโ scripts/
|
|
399
|
+
โ โโโ e2e-diff.sh # Before/after functional comparison against real AWS
|
|
400
|
+
โ
|
|
401
|
+
โโโ docs/ # Documentation
|
|
402
|
+
โ โโโ adr/ # Architecture decision records
|
|
403
|
+
โ โโโ Architecture.md # System architecture and design patterns
|
|
404
|
+
โ โโโ LOGGING_ARCHITECTURE.md # Logging system documentation
|
|
405
|
+
โ
|
|
406
|
+
โโโ tests/ # Test suite โ runs with ZERO AWS credentials (moto)
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
## ๐งช Testing
|
|
410
|
+
|
|
411
|
+
> [!NOTE]
|
|
412
|
+
> The suite needs no AWS credentials: moto fakes AWS, and the test fixtures
|
|
413
|
+
> force fake credentials so no test can ever touch a real account.
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
# Run the full suite (coverage is reported automatically)
|
|
417
|
+
poetry run pytest
|
|
418
|
+
|
|
419
|
+
# Run one test file
|
|
420
|
+
poetry run pytest tests/test_engine.py
|
|
421
|
+
|
|
422
|
+
# Quick smoke checks (help, dry-run, formats)
|
|
423
|
+
./run_quick_tests.sh
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
After merging a change that touches scan behaviour, verify against real
|
|
427
|
+
AWS with the before/after comparison script:
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
scripts/e2e-diff.sh # compares origin/main~1 vs origin/main
|
|
431
|
+
scripts/e2e-diff.sh --tag-key team # exercise the tag-scan path too
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## ๐ Troubleshooting
|
|
435
|
+
|
|
436
|
+
### Common Issues
|
|
437
|
+
|
|
438
|
+
1. **AWS Credentials**: Ensure AWS credentials are properly configured
|
|
439
|
+
```bash
|
|
440
|
+
aws sts get-caller-identity
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
2. **Python Version**: Verify Python 3.10+ is installed
|
|
444
|
+
```bash
|
|
445
|
+
python3 --version
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
3. **Dependencies**: Reinstall dependencies if needed
|
|
449
|
+
```bash
|
|
450
|
+
poetry install --no-cache
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
4. **Permissions**: Ensure your AWS user/role has necessary permissions for the services you're scanning
|
|
454
|
+
|
|
455
|
+
### Debug and Logging Troubleshooting
|
|
456
|
+
|
|
457
|
+
The advanced logging system provides powerful debugging capabilities:
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
# Basic debug information
|
|
461
|
+
poetry run aws-inventory scan --debug --dry-run
|
|
462
|
+
|
|
463
|
+
# Verbose AWS API tracing for troubleshooting
|
|
464
|
+
poetry run aws-inventory --verbose --log-file debug-trace.log scan --debug --service ec2
|
|
465
|
+
|
|
466
|
+
# Check debug log files (automatically created)
|
|
467
|
+
ls .debug_logs/
|
|
468
|
+
|
|
469
|
+
# Monitor real-time logging
|
|
470
|
+
tail -f .debug_logs/aws_scanner_debug_*.log
|
|
471
|
+
|
|
472
|
+
# Filter AWS API calls
|
|
473
|
+
grep -E "(boto|botocore|HTTP)" .debug_logs/aws_scanner_debug_*.log
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
Common logging issues: no AWS API logs usually means one of `--debug` or
|
|
477
|
+
`--verbose` is missing (both are required, and `--verbose` goes before
|
|
478
|
+
`scan`); for sequential, readable debugging use `--max-workers 1`; if log
|
|
479
|
+
files are missing, check permissions on the `.debug_logs/` directory.
|
|
480
|
+
|
|
481
|
+
> [!Tip]
|
|
482
|
+
> **๐ง Advanced Troubleshooting**: For detailed logging troubleshooting and configuration options, see [Logging Architecture - Troubleshooting Section](docs/LOGGING_ARCHITECTURE.md#troubleshooting).
|
|
483
|
+
|
|
484
|
+
## ๐ Quick Reference
|
|
485
|
+
|
|
486
|
+
### Most Common Commands
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
# Quick scan with basic output
|
|
490
|
+
poetry run aws-inventory scan --regions us-east-1
|
|
491
|
+
|
|
492
|
+
# Debug mode with detailed logging
|
|
493
|
+
poetry run aws-inventory scan --debug --regions us-east-1
|
|
494
|
+
|
|
495
|
+
# Full AWS API tracing (development/troubleshooting)
|
|
496
|
+
poetry run aws-inventory --verbose --log-file trace.log scan --debug --service ec2
|
|
497
|
+
|
|
498
|
+
# Tag-based filtering across all AWS services
|
|
499
|
+
poetry run aws-inventory scan --all-services --tag-key Environment --tag-value Production
|
|
500
|
+
|
|
501
|
+
# Production audit with comprehensive logging
|
|
502
|
+
poetry run aws-inventory --verbose --log-file audit.log scan --debug \
|
|
503
|
+
--tag-key Environment --tag-value Production --format json --output audit.json
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Flag Combinations Guide
|
|
507
|
+
|
|
508
|
+
| Scenario | Command Pattern | Purpose |
|
|
509
|
+
|------------------|----------------------------------------------------------|--------------------------------|
|
|
510
|
+
| **Basic Scan** | `poetry run aws-inventory scan` | Standard resource discovery |
|
|
511
|
+
| **Debug Mode** | `poetry run aws-inventory scan --debug` | Detailed execution information |
|
|
512
|
+
| **API Tracing** | `poetry run aws-inventory --verbose scan --debug` | Full AWS API call logging |
|
|
513
|
+
| **Custom Logs** | `poetry run aws-inventory --log-file path scan --debug` | Custom log file location |
|
|
514
|
+
| **All Services** | `poetry run aws-inventory scan --all-services --tag-key X` | Discover 100+ AWS services |
|
|
515
|
+
|
|
516
|
+
## ๐ Documentation
|
|
517
|
+
|
|
518
|
+
The project includes comprehensive documentation covering all aspects of the system:
|
|
519
|
+
|
|
520
|
+
- [Architecture Documentation](docs/Architecture.md) โ system design, component interactions, and patterns
|
|
521
|
+
- [Architecture Decision Records](docs/adr/) โ why things are built the way they are
|
|
522
|
+
- [Shell Completion](docs/SHELL_COMPLETION.md) โ tab-completion setup for the CLI
|
|
523
|
+
- [Logging Architecture](docs/LOGGING_ARCHITECTURE.md) โ the logging system: API tracing, configuration, integration patterns, troubleshooting, performance
|
|
524
|
+
|
|
525
|
+
## ๐ค Contributing
|
|
526
|
+
|
|
527
|
+
1. Fork the repository
|
|
528
|
+
2. Create a feature branch: `git checkout -b feature/amazing-feature`
|
|
529
|
+
3. Install development dependencies: Use [`./setup.sh`](./setup.sh)
|
|
530
|
+
4. Set up pre-commit hooks: `pre-commit install --install-hooks`
|
|
531
|
+
5. Make your changes and run tests: `poetry run pytest`
|
|
532
|
+
6. Test logging changes: `poetry run aws-inventory --verbose scan --debug --dry-run`
|
|
533
|
+
7. Commit with a conventional-commit message (titles feed the release changelog): `git commit -m 'feat: add amazing feature'`
|
|
534
|
+
8. Push to the branch: `git push origin feature/amazing-feature`
|
|
535
|
+
9. Open a Pull Request
|
|
536
|
+
|
|
537
|
+
> [!TIP]
|
|
538
|
+
> **Development Notes:**
|
|
539
|
+
> - Use the debug and verbose flags extensively during development
|
|
540
|
+
> - Check the logging architecture documentation when modifying logging behavior
|
|
541
|
+
> - Ensure all new features include appropriate logging and error handling
|
|
542
|
+
|
|
543
|
+
## ๐ License
|
|
544
|
+
|
|
545
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
546
|
+
|
|
547
|
+
## ๐ Acknowledgments
|
|
548
|
+
|
|
549
|
+
- Built with [Typer](https://typer.tiangolo.com/) for CLI interface
|
|
550
|
+
- Styled with [Rich](https://rich.readthedocs.io/) for beautiful console output
|
|
551
|
+
- Powered by [Boto3](https://boto3.amazonaws.com/) for AWS integration
|
|
552
|
+
- Managed with [Poetry](https://python-poetry.org/) for dependency management
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
556
|
+
> _Made with โค๏ธ for the AWS community_
|
|
557
|
+
|