runbooks 1.1.3__py3-none-any.whl → 1.1.5__py3-none-any.whl
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.
- runbooks/__init__.py +31 -2
- runbooks/__init___optimized.py +18 -4
- runbooks/_platform/__init__.py +1 -5
- runbooks/_platform/core/runbooks_wrapper.py +141 -138
- runbooks/aws2/accuracy_validator.py +812 -0
- runbooks/base.py +7 -0
- runbooks/cfat/WEIGHT_CONFIG_README.md +1 -1
- runbooks/cfat/assessment/compliance.py +8 -8
- runbooks/cfat/assessment/runner.py +1 -0
- runbooks/cfat/cloud_foundations_assessment.py +227 -239
- runbooks/cfat/models.py +6 -2
- runbooks/cfat/tests/__init__.py +6 -1
- runbooks/cli/__init__.py +13 -0
- runbooks/cli/commands/cfat.py +274 -0
- runbooks/cli/commands/finops.py +1164 -0
- runbooks/cli/commands/inventory.py +379 -0
- runbooks/cli/commands/operate.py +239 -0
- runbooks/cli/commands/security.py +248 -0
- runbooks/cli/commands/validation.py +825 -0
- runbooks/cli/commands/vpc.py +310 -0
- runbooks/cli/registry.py +107 -0
- runbooks/cloudops/__init__.py +23 -30
- runbooks/cloudops/base.py +96 -107
- runbooks/cloudops/cost_optimizer.py +549 -547
- runbooks/cloudops/infrastructure_optimizer.py +5 -4
- runbooks/cloudops/interfaces.py +226 -227
- runbooks/cloudops/lifecycle_manager.py +5 -4
- runbooks/cloudops/mcp_cost_validation.py +252 -235
- runbooks/cloudops/models.py +78 -53
- runbooks/cloudops/monitoring_automation.py +5 -4
- runbooks/cloudops/notebook_framework.py +179 -215
- runbooks/cloudops/security_enforcer.py +125 -159
- runbooks/common/accuracy_validator.py +11 -0
- runbooks/common/aws_pricing.py +349 -326
- runbooks/common/aws_pricing_api.py +211 -212
- runbooks/common/aws_profile_manager.py +341 -0
- runbooks/common/aws_utils.py +75 -80
- runbooks/common/business_logic.py +127 -105
- runbooks/common/cli_decorators.py +36 -60
- runbooks/common/comprehensive_cost_explorer_integration.py +456 -464
- runbooks/common/cross_account_manager.py +198 -205
- runbooks/common/date_utils.py +27 -39
- runbooks/common/decorators.py +235 -0
- runbooks/common/dry_run_examples.py +173 -208
- runbooks/common/dry_run_framework.py +157 -155
- runbooks/common/enhanced_exception_handler.py +15 -4
- runbooks/common/enhanced_logging_example.py +50 -64
- runbooks/common/enhanced_logging_integration_example.py +65 -37
- runbooks/common/env_utils.py +16 -16
- runbooks/common/error_handling.py +40 -38
- runbooks/common/lazy_loader.py +41 -23
- runbooks/common/logging_integration_helper.py +79 -86
- runbooks/common/mcp_cost_explorer_integration.py +478 -495
- runbooks/common/mcp_integration.py +63 -74
- runbooks/common/memory_optimization.py +140 -118
- runbooks/common/module_cli_base.py +37 -58
- runbooks/common/organizations_client.py +176 -194
- runbooks/common/patterns.py +204 -0
- runbooks/common/performance_monitoring.py +67 -71
- runbooks/common/performance_optimization_engine.py +283 -274
- runbooks/common/profile_utils.py +248 -39
- runbooks/common/rich_utils.py +643 -92
- runbooks/common/sre_performance_suite.py +177 -186
- runbooks/enterprise/__init__.py +1 -1
- runbooks/enterprise/logging.py +144 -106
- runbooks/enterprise/security.py +187 -204
- runbooks/enterprise/validation.py +43 -56
- runbooks/finops/__init__.py +29 -33
- runbooks/finops/account_resolver.py +1 -1
- runbooks/finops/advanced_optimization_engine.py +980 -0
- runbooks/finops/automation_core.py +268 -231
- runbooks/finops/business_case_config.py +184 -179
- runbooks/finops/cli.py +660 -139
- runbooks/finops/commvault_ec2_analysis.py +157 -164
- runbooks/finops/compute_cost_optimizer.py +336 -320
- runbooks/finops/config.py +20 -20
- runbooks/finops/cost_optimizer.py +488 -622
- runbooks/finops/cost_processor.py +332 -214
- runbooks/finops/dashboard_runner.py +1006 -172
- runbooks/finops/ebs_cost_optimizer.py +991 -657
- runbooks/finops/elastic_ip_optimizer.py +317 -257
- runbooks/finops/enhanced_mcp_integration.py +340 -0
- runbooks/finops/enhanced_progress.py +40 -37
- runbooks/finops/enhanced_trend_visualization.py +3 -2
- runbooks/finops/enterprise_wrappers.py +230 -292
- runbooks/finops/executive_export.py +203 -160
- runbooks/finops/helpers.py +130 -288
- runbooks/finops/iam_guidance.py +1 -1
- runbooks/finops/infrastructure/__init__.py +80 -0
- runbooks/finops/infrastructure/commands.py +506 -0
- runbooks/finops/infrastructure/load_balancer_optimizer.py +866 -0
- runbooks/finops/infrastructure/vpc_endpoint_optimizer.py +832 -0
- runbooks/finops/markdown_exporter.py +338 -175
- runbooks/finops/mcp_validator.py +1952 -0
- runbooks/finops/nat_gateway_optimizer.py +1513 -482
- runbooks/finops/network_cost_optimizer.py +657 -587
- runbooks/finops/notebook_utils.py +226 -188
- runbooks/finops/optimization_engine.py +1136 -0
- runbooks/finops/optimizer.py +25 -29
- runbooks/finops/rds_snapshot_optimizer.py +367 -411
- runbooks/finops/reservation_optimizer.py +427 -363
- runbooks/finops/scenario_cli_integration.py +77 -78
- runbooks/finops/scenarios.py +1278 -439
- runbooks/finops/schemas.py +218 -182
- runbooks/finops/snapshot_manager.py +2289 -0
- runbooks/finops/tests/test_finops_dashboard.py +3 -3
- runbooks/finops/tests/test_reference_images_validation.py +2 -2
- runbooks/finops/tests/test_single_account_features.py +17 -17
- runbooks/finops/tests/validate_test_suite.py +1 -1
- runbooks/finops/types.py +3 -3
- runbooks/finops/validation_framework.py +263 -269
- runbooks/finops/vpc_cleanup_exporter.py +191 -146
- runbooks/finops/vpc_cleanup_optimizer.py +593 -575
- runbooks/finops/workspaces_analyzer.py +171 -182
- runbooks/hitl/enhanced_workflow_engine.py +1 -1
- runbooks/integration/__init__.py +89 -0
- runbooks/integration/mcp_integration.py +1920 -0
- runbooks/inventory/CLAUDE.md +816 -0
- runbooks/inventory/README.md +3 -3
- runbooks/inventory/Tests/common_test_data.py +30 -30
- runbooks/inventory/__init__.py +2 -2
- runbooks/inventory/cloud_foundations_integration.py +144 -149
- runbooks/inventory/collectors/aws_comprehensive.py +28 -11
- runbooks/inventory/collectors/aws_networking.py +111 -101
- runbooks/inventory/collectors/base.py +4 -0
- runbooks/inventory/core/collector.py +495 -313
- runbooks/inventory/discovery.md +2 -2
- runbooks/inventory/drift_detection_cli.py +69 -96
- runbooks/inventory/find_ec2_security_groups.py +1 -1
- runbooks/inventory/inventory_mcp_cli.py +48 -46
- runbooks/inventory/list_rds_snapshots_aggregator.py +192 -208
- runbooks/inventory/mcp_inventory_validator.py +549 -465
- runbooks/inventory/mcp_vpc_validator.py +359 -442
- runbooks/inventory/organizations_discovery.py +56 -52
- runbooks/inventory/rich_inventory_display.py +33 -32
- runbooks/inventory/unified_validation_engine.py +278 -251
- runbooks/inventory/vpc_analyzer.py +733 -696
- runbooks/inventory/vpc_architecture_validator.py +293 -348
- runbooks/inventory/vpc_dependency_analyzer.py +382 -378
- runbooks/inventory/vpc_flow_analyzer.py +3 -3
- runbooks/main.py +152 -9147
- runbooks/main_final.py +91 -60
- runbooks/main_minimal.py +22 -10
- runbooks/main_optimized.py +131 -100
- runbooks/main_ultra_minimal.py +7 -2
- runbooks/mcp/__init__.py +36 -0
- runbooks/mcp/integration.py +679 -0
- runbooks/metrics/dora_metrics_engine.py +2 -2
- runbooks/monitoring/performance_monitor.py +9 -4
- runbooks/operate/dynamodb_operations.py +3 -1
- runbooks/operate/ec2_operations.py +145 -137
- runbooks/operate/iam_operations.py +146 -152
- runbooks/operate/mcp_integration.py +1 -1
- runbooks/operate/networking_cost_heatmap.py +33 -10
- runbooks/operate/privatelink_operations.py +1 -1
- runbooks/operate/rds_operations.py +223 -254
- runbooks/operate/s3_operations.py +107 -118
- runbooks/operate/vpc_endpoints.py +1 -1
- runbooks/operate/vpc_operations.py +648 -618
- runbooks/remediation/base.py +1 -1
- runbooks/remediation/commons.py +10 -7
- runbooks/remediation/commvault_ec2_analysis.py +71 -67
- runbooks/remediation/ec2_unattached_ebs_volumes.py +1 -0
- runbooks/remediation/multi_account.py +24 -21
- runbooks/remediation/rds_snapshot_list.py +91 -65
- runbooks/remediation/remediation_cli.py +92 -146
- runbooks/remediation/universal_account_discovery.py +83 -79
- runbooks/remediation/workspaces_list.py +49 -44
- runbooks/security/__init__.py +19 -0
- runbooks/security/assessment_runner.py +1150 -0
- runbooks/security/baseline_checker.py +812 -0
- runbooks/security/cloudops_automation_security_validator.py +509 -535
- runbooks/security/compliance_automation_engine.py +17 -17
- runbooks/security/config/__init__.py +2 -2
- runbooks/security/config/compliance_config.py +50 -50
- runbooks/security/config_template_generator.py +63 -76
- runbooks/security/enterprise_security_framework.py +1 -1
- runbooks/security/executive_security_dashboard.py +519 -508
- runbooks/security/integration_test_enterprise_security.py +5 -3
- runbooks/security/multi_account_security_controls.py +959 -1210
- runbooks/security/real_time_security_monitor.py +422 -444
- runbooks/security/run_script.py +1 -1
- runbooks/security/security_baseline_tester.py +1 -1
- runbooks/security/security_cli.py +143 -112
- runbooks/security/test_2way_validation.py +439 -0
- runbooks/security/two_way_validation_framework.py +852 -0
- runbooks/sre/mcp_reliability_engine.py +6 -6
- runbooks/sre/production_monitoring_framework.py +167 -177
- runbooks/tdd/__init__.py +15 -0
- runbooks/tdd/cli.py +1071 -0
- runbooks/utils/__init__.py +14 -17
- runbooks/utils/logger.py +7 -2
- runbooks/utils/version_validator.py +51 -48
- runbooks/validation/__init__.py +6 -6
- runbooks/validation/cli.py +9 -3
- runbooks/validation/comprehensive_2way_validator.py +754 -708
- runbooks/validation/mcp_validator.py +906 -228
- runbooks/validation/terraform_citations_validator.py +104 -115
- runbooks/validation/terraform_drift_detector.py +447 -451
- runbooks/vpc/README.md +617 -0
- runbooks/vpc/__init__.py +8 -1
- runbooks/vpc/analyzer.py +577 -0
- runbooks/vpc/cleanup_wrapper.py +476 -413
- runbooks/vpc/cli_cloudtrail_commands.py +339 -0
- runbooks/vpc/cli_mcp_validation_commands.py +480 -0
- runbooks/vpc/cloudtrail_audit_integration.py +717 -0
- runbooks/vpc/config.py +92 -97
- runbooks/vpc/cost_engine.py +411 -148
- runbooks/vpc/cost_explorer_integration.py +553 -0
- runbooks/vpc/cross_account_session.py +101 -106
- runbooks/vpc/enhanced_mcp_validation.py +917 -0
- runbooks/vpc/eni_gate_validator.py +961 -0
- runbooks/vpc/heatmap_engine.py +190 -162
- runbooks/vpc/mcp_no_eni_validator.py +681 -640
- runbooks/vpc/nat_gateway_optimizer.py +358 -0
- runbooks/vpc/networking_wrapper.py +15 -8
- runbooks/vpc/pdca_remediation_planner.py +528 -0
- runbooks/vpc/performance_optimized_analyzer.py +219 -231
- runbooks/vpc/runbooks_adapter.py +1167 -241
- runbooks/vpc/tdd_red_phase_stubs.py +601 -0
- runbooks/vpc/test_data_loader.py +358 -0
- runbooks/vpc/tests/conftest.py +314 -4
- runbooks/vpc/tests/test_cleanup_framework.py +1022 -0
- runbooks/vpc/tests/test_cost_engine.py +0 -2
- runbooks/vpc/topology_generator.py +326 -0
- runbooks/vpc/unified_scenarios.py +1302 -1129
- runbooks/vpc/vpc_cleanup_integration.py +1943 -1115
- runbooks-1.1.5.dist-info/METADATA +328 -0
- {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/RECORD +233 -200
- runbooks/finops/README.md +0 -414
- runbooks/finops/accuracy_cross_validator.py +0 -647
- runbooks/finops/business_cases.py +0 -950
- runbooks/finops/dashboard_router.py +0 -922
- runbooks/finops/ebs_optimizer.py +0 -956
- runbooks/finops/embedded_mcp_validator.py +0 -1629
- runbooks/finops/enhanced_dashboard_runner.py +0 -527
- runbooks/finops/finops_dashboard.py +0 -584
- runbooks/finops/finops_scenarios.py +0 -1218
- runbooks/finops/legacy_migration.py +0 -730
- runbooks/finops/multi_dashboard.py +0 -1519
- runbooks/finops/single_dashboard.py +0 -1113
- runbooks/finops/unlimited_scenarios.py +0 -393
- runbooks-1.1.3.dist-info/METADATA +0 -799
- {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/WHEEL +0 -0
- {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/entry_points.txt +0 -0
- {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/licenses/LICENSE +0 -0
- {runbooks-1.1.3.dist-info → runbooks-1.1.5.dist-info}/top_level.txt +0 -0
runbooks/vpc/README.md
CHANGED
@@ -69,6 +69,7 @@ Key capabilities include:
|
|
69
69
|
- Centralized configuration via TOML files
|
70
70
|
- Environment-specific settings
|
71
71
|
- Profile-based authentication management
|
72
|
+
- **NEW**: YAML campaign configuration for multi-Landing Zone VPC cleanup analysis
|
72
73
|
- **Rich Terminal UI**: Beautiful terminal output with progress indicators and charts
|
73
74
|
- **Export Options**:
|
74
75
|
- JSON export for automation integration
|
@@ -246,6 +247,622 @@ runbooks vpc cleanup --dry-run --profile production
|
|
246
247
|
runbooks vpc analyze --utilization --profile production
|
247
248
|
```
|
248
249
|
|
250
|
+
### **NEW: Config-Driven VPC Cleanup Campaign Analysis**
|
251
|
+
|
252
|
+
**AWS-25 Campaign Example** ($101,247.67/year realized savings):
|
253
|
+
|
254
|
+
```bash
|
255
|
+
# Config-driven multi-VPC cleanup analysis
|
256
|
+
runbooks vpc analyze \
|
257
|
+
--config examples/vpc-cleanup/aws25-campaign-config.yaml \
|
258
|
+
--profile ams-admin-Billing-ReadOnlyAccess-909135376185
|
259
|
+
```
|
260
|
+
|
261
|
+
**Campaign Results Output**:
|
262
|
+
```
|
263
|
+
╭─ VPC Cleanup Campaign: AWS-25 ─────────────────────────╮
|
264
|
+
│ AWS Profile: ams-admin-Billing-ReadOnlyAccess-909135376185 │
|
265
|
+
│ VPCs Analyzed: 6 │
|
266
|
+
│ Accounts: 909135376185, 335083429030 │
|
267
|
+
│ Regions: ap-southeast-2 │
|
268
|
+
╰─────────────────────────────────────────────────────────╯
|
269
|
+
|
270
|
+
╭─ Campaign Results ──────────────────────────────────────╮
|
271
|
+
│ VPC ID Account Deletion Annual │
|
272
|
+
│ Date Savings │
|
273
|
+
├─────────────────────────────────────────────────────────┤
|
274
|
+
│ vpc-0e113622eb4... 909135376185 2025-09-10 $0.00 │
|
275
|
+
│ vpc-090b313795... 909135376185 2025-09-08 $0.00 │
|
276
|
+
│ vpc-016a2f1e86... 909135376185 2025-08-04 $88,215.38 │
|
277
|
+
│ vpc-08df1f9529... 335083429030 2025-09-10 $241.53 │
|
278
|
+
│ vpc-0eabfc3260... 335083429030 2025-09-08 $110.65 │
|
279
|
+
│ vpc-0f1a336ec8... 335083429030 2025-08-04 $12,680.11 │
|
280
|
+
╰─────────────────────────────────────────────────────────╯
|
281
|
+
|
282
|
+
✓ Total Campaign Savings: $101,247.67/year
|
283
|
+
```
|
284
|
+
|
285
|
+
**Campaign Config Schema** (YAML):
|
286
|
+
```yaml
|
287
|
+
campaign_metadata:
|
288
|
+
campaign_id: "AWS-25"
|
289
|
+
aws_billing_profile: "ams-admin-Billing-ReadOnlyAccess-909135376185"
|
290
|
+
|
291
|
+
deleted_vpcs:
|
292
|
+
- vpc_id: "vpc-0e113622eb492c654"
|
293
|
+
account_id: "909135376185"
|
294
|
+
region: "ap-southeast-2"
|
295
|
+
deletion_date: "2025-09-10"
|
296
|
+
|
297
|
+
cost_explorer_config:
|
298
|
+
metrics: ["UnblendedCost"]
|
299
|
+
granularity_monthly: "MONTHLY"
|
300
|
+
|
301
|
+
attribution_rules:
|
302
|
+
vpc_specific_services:
|
303
|
+
attribution_percentage: 100
|
304
|
+
confidence_level: "HIGH (95%)"
|
305
|
+
```
|
306
|
+
|
307
|
+
**Multi-Landing Zone Deployment**:
|
308
|
+
```bash
|
309
|
+
# Create custom campaign config
|
310
|
+
cp examples/vpc-cleanup/aws25-campaign-config.yaml config/my_lz_config.yaml
|
311
|
+
|
312
|
+
# Update VPC list and campaign metadata
|
313
|
+
vim config/my_lz_config.yaml
|
314
|
+
|
315
|
+
# Execute analysis
|
316
|
+
runbooks vpc analyze --config config/my_lz_config.yaml --profile my-billing-profile
|
317
|
+
```
|
318
|
+
|
319
|
+
---
|
320
|
+
|
321
|
+
## Multi-Landing Zone Deployment Patterns
|
322
|
+
|
323
|
+
### Deployment Patterns Overview
|
324
|
+
|
325
|
+
#### Pattern Comparison Matrix
|
326
|
+
|
327
|
+
| Pattern | Use Case | Complexity | VPC Count | Account Count | Execution Time |
|
328
|
+
|---------|----------|------------|-----------|---------------|----------------|
|
329
|
+
| **Single-Account LZ** | Single AWS account cleanup | Low | 1-10 | 1 | 5-15 min |
|
330
|
+
| **Multi-Account Org** | AWS Organizations cleanup | Medium | 10-50 | 3-20 | 30-90 min |
|
331
|
+
| **Custom Attribution** | Fine-tuned confidence rules | Medium | Any | Any | Same as base |
|
332
|
+
| **Large-Scale LZ** | Enterprise-wide cleanup | High | 50+ | 20+ | 2-4 hours |
|
333
|
+
|
334
|
+
---
|
335
|
+
|
336
|
+
### Pattern 1: Single-Account Landing Zone
|
337
|
+
|
338
|
+
**Use Case**: Single AWS account with multiple VPCs deleted over time period.
|
339
|
+
|
340
|
+
**Typical Scenarios**:
|
341
|
+
- Dev/Test account cleanup
|
342
|
+
- Single-account sandbox decommission
|
343
|
+
- Departmental AWS account cleanup
|
344
|
+
|
345
|
+
#### Prerequisites
|
346
|
+
|
347
|
+
**Identify Deleted VPCs via CloudTrail**:
|
348
|
+
```bash
|
349
|
+
# Query CloudTrail for DeleteVpc events
|
350
|
+
AWS_PROFILE=account-profile aws cloudtrail lookup-events \
|
351
|
+
--lookup-attributes AttributeKey=EventName,AttributeValue=DeleteVpc \
|
352
|
+
--start-time "2025-07-01" \
|
353
|
+
--end-time "2025-10-01"
|
354
|
+
```
|
355
|
+
|
356
|
+
**MCP Alternative**:
|
357
|
+
```bash
|
358
|
+
# Using MCP CloudTrail tool
|
359
|
+
mcp__cloudtrail__lookup_events \
|
360
|
+
--attribute-key EventName \
|
361
|
+
--attribute-value DeleteVpc \
|
362
|
+
--start-time "30 days ago"
|
363
|
+
```
|
364
|
+
|
365
|
+
#### Deployment Steps
|
366
|
+
|
367
|
+
**Create Campaign Config**:
|
368
|
+
```yaml
|
369
|
+
# config/lz_acme_dev_config.yaml
|
370
|
+
campaign_metadata:
|
371
|
+
campaign_id: "LZ-ACME-DEV-Q3-2025"
|
372
|
+
campaign_name: "ACME Dev Account VPC Cleanup - Q3 2025"
|
373
|
+
aws_billing_profile: "acme-dev-billing-readonly"
|
374
|
+
|
375
|
+
deleted_vpcs:
|
376
|
+
- vpc_id: "vpc-0abc123def456789a"
|
377
|
+
account_id: "123456789012"
|
378
|
+
deletion_date: "2025-09-15"
|
379
|
+
deletion_principal: "devops-team@acme.com"
|
380
|
+
pre_deletion_baseline_months: 3
|
381
|
+
|
382
|
+
cost_explorer_config:
|
383
|
+
metrics: ["UnblendedCost"]
|
384
|
+
pre_deletion_baseline:
|
385
|
+
granularity_monthly: "MONTHLY"
|
386
|
+
months_before_deletion: 3
|
387
|
+
post_deletion_validation:
|
388
|
+
days_after_deletion: 30
|
389
|
+
|
390
|
+
attribution_rules:
|
391
|
+
vpc_specific_services:
|
392
|
+
confidence_level: "HIGH (95%)"
|
393
|
+
attribution_percentage: 100
|
394
|
+
service_patterns: ["Amazon Virtual Private Cloud", "AWS PrivateLink"]
|
395
|
+
vpc_related_services:
|
396
|
+
confidence_level: "MEDIUM (85%)"
|
397
|
+
attribution_percentage: 70
|
398
|
+
service_patterns: ["Amazon Elastic Compute Cloud - Compute"]
|
399
|
+
```
|
400
|
+
|
401
|
+
**Execute Analysis**:
|
402
|
+
```bash
|
403
|
+
./run_vpc_savings_analysis.sh ../config/lz_acme_dev_config.yaml
|
404
|
+
```
|
405
|
+
|
406
|
+
---
|
407
|
+
|
408
|
+
### Pattern 2: Multi-Account Organization
|
409
|
+
|
410
|
+
**Use Case**: AWS Organizations with VPCs deleted across multiple member accounts.
|
411
|
+
|
412
|
+
**Typical Scenarios**:
|
413
|
+
- Organization-wide quarterly cleanup
|
414
|
+
- Multi-account migration completion
|
415
|
+
- Cross-account infrastructure decommission
|
416
|
+
|
417
|
+
#### Prerequisites
|
418
|
+
1. **Centralized Billing Account**: Master payer with Cost Explorer enabled
|
419
|
+
2. **Multi-Account CloudTrail**: Query across all member accounts
|
420
|
+
3. **IAM Permissions**: Read-only Cost Explorer in master account
|
421
|
+
|
422
|
+
#### Deployment Steps
|
423
|
+
|
424
|
+
**Query CloudTrail Across Organization**:
|
425
|
+
```bash
|
426
|
+
# Query each account for VPC deletions
|
427
|
+
for profile in billing-account ops-account dev-account; do
|
428
|
+
AWS_PROFILE=$profile aws cloudtrail lookup-events \
|
429
|
+
--lookup-attributes AttributeKey=EventName,AttributeValue=DeleteVpc \
|
430
|
+
--start-time "2025-07-01"
|
431
|
+
done > vpc_deletions_org_wide.json
|
432
|
+
```
|
433
|
+
|
434
|
+
**Create Multi-Account Config**:
|
435
|
+
```yaml
|
436
|
+
# config/org_q3_cleanup_config.yaml
|
437
|
+
campaign_metadata:
|
438
|
+
campaign_id: "ORG-WIDE-CLEANUP-Q3-2025"
|
439
|
+
aws_billing_profile: "org-master-billing-readonly"
|
440
|
+
|
441
|
+
deleted_vpcs:
|
442
|
+
# Operations Account VPCs
|
443
|
+
- vpc_id: "vpc-ops-001-primary"
|
444
|
+
account_id: "111111111111"
|
445
|
+
deletion_date: "2025-08-10"
|
446
|
+
|
447
|
+
# Development Account VPCs
|
448
|
+
- vpc_id: "vpc-dev-001-sandbox"
|
449
|
+
account_id: "222222222222"
|
450
|
+
deletion_date: "2025-08-15"
|
451
|
+
|
452
|
+
# Production Account VPCs
|
453
|
+
- vpc_id: "vpc-prod-legacy-001"
|
454
|
+
account_id: "444444444444"
|
455
|
+
deletion_date: "2025-09-05"
|
456
|
+
pre_deletion_baseline_months: 6 # Longer baseline for prod
|
457
|
+
```
|
458
|
+
|
459
|
+
**Execute with Organization Billing**:
|
460
|
+
```bash
|
461
|
+
./run_vpc_savings_analysis.sh ../config/org_q3_cleanup_config.yaml
|
462
|
+
```
|
463
|
+
|
464
|
+
**Analyze Consolidated Results**:
|
465
|
+
```bash
|
466
|
+
# Calculate total savings by account
|
467
|
+
awk -F',' 'NR>1 {sum[$2]+=$(NF-5)} END {for (acct in sum) print acct, sum[acct]}' \
|
468
|
+
../artifacts/org_q3_vpc_cleanup_savings.csv
|
469
|
+
```
|
470
|
+
|
471
|
+
**Expected Output**:
|
472
|
+
```
|
473
|
+
111111111111 $15,234.56/year (Ops Account)
|
474
|
+
222222222222 $23,456.78/year (Dev Account)
|
475
|
+
444444444444 $45,678.90/year (Prod Account)
|
476
|
+
---
|
477
|
+
Total: $93,271.47/year
|
478
|
+
```
|
479
|
+
|
480
|
+
---
|
481
|
+
|
482
|
+
### Pattern 3: Custom Attribution Rules
|
483
|
+
|
484
|
+
**Use Case**: Adjust attribution percentages for specific environments.
|
485
|
+
|
486
|
+
#### Scenario A: Single-VPC Account (Higher Confidence)
|
487
|
+
|
488
|
+
**Rationale**: When account only had one VPC, attribution more accurate.
|
489
|
+
|
490
|
+
```yaml
|
491
|
+
attribution_rules:
|
492
|
+
vpc_specific_services:
|
493
|
+
confidence_level: "HIGH (98%)"
|
494
|
+
attribution_percentage: 100
|
495
|
+
vpc_related_services:
|
496
|
+
confidence_level: "MEDIUM (90%)"
|
497
|
+
attribution_percentage: 85 # Increased from default 70%
|
498
|
+
other_services:
|
499
|
+
confidence_level: "MEDIUM (85%)"
|
500
|
+
attribution_percentage: 50 # Increased from default 30%
|
501
|
+
```
|
502
|
+
|
503
|
+
#### Scenario B: Kubernetes/EKS Cluster Cleanup
|
504
|
+
|
505
|
+
**Rationale**: EKS workloads have most services VPC-bound.
|
506
|
+
|
507
|
+
```yaml
|
508
|
+
attribution_rules:
|
509
|
+
vpc_related_services:
|
510
|
+
confidence_level: "HIGH (92%)"
|
511
|
+
attribution_percentage: 90 # Higher for EKS
|
512
|
+
service_patterns:
|
513
|
+
- "Amazon Elastic Compute Cloud - Compute"
|
514
|
+
- "Amazon Elastic Container Service for Kubernetes"
|
515
|
+
- "Amazon EKS"
|
516
|
+
```
|
517
|
+
|
518
|
+
#### Scenario C: Data Processing Workload (S3-Heavy)
|
519
|
+
|
520
|
+
**Rationale**: S3 data lake workloads have high non-VPC costs.
|
521
|
+
|
522
|
+
```yaml
|
523
|
+
attribution_rules:
|
524
|
+
other_services:
|
525
|
+
confidence_level: "LOW (<75%)"
|
526
|
+
attribution_percentage: 15 # Lower - S3 costs not VPC-related
|
527
|
+
```
|
528
|
+
|
529
|
+
---
|
530
|
+
|
531
|
+
### Best Practices
|
532
|
+
|
533
|
+
#### 1. Config Organization
|
534
|
+
```
|
535
|
+
config/
|
536
|
+
├── aws25_campaign_config.yaml # Reference template
|
537
|
+
├── lz_dev_q3_2025_config.yaml # Dev account Q3
|
538
|
+
├── lz_prod_q3_2025_config.yaml # Prod account Q3
|
539
|
+
└── org_wide_q3_2025_config.yaml # Organization-wide
|
540
|
+
```
|
541
|
+
|
542
|
+
#### 2. Naming Conventions
|
543
|
+
- **Campaign ID**: `[SCOPE]-[NAME]-[TIME]` (e.g., `LZ-ACME-DEV-Q3-2025`)
|
544
|
+
- **Config File**: `[lz]_[account]_[period]_config.yaml`
|
545
|
+
- **Output File**: `[campaign_id]_savings.csv`
|
546
|
+
|
547
|
+
#### 3. Attribution Tuning
|
548
|
+
- **Single-VPC Accounts**: Increase attribution percentages (85% → 90%)
|
549
|
+
- **Multi-VPC Accounts**: Keep conservative defaults (70%, 30%)
|
550
|
+
- **EKS Clusters**: Increase vpc_related to 90%
|
551
|
+
- **S3-Heavy Workloads**: Decrease other_services to 15%
|
552
|
+
|
553
|
+
---
|
554
|
+
|
555
|
+
## Troubleshooting
|
556
|
+
|
557
|
+
### Cost Explorer Issues
|
558
|
+
|
559
|
+
#### Issue: VPC Not in Cost Explorer Results
|
560
|
+
|
561
|
+
**Symptom**: `$0.00` savings for VPCs known to have costs.
|
562
|
+
|
563
|
+
**Root Cause**: Cost Explorer provides account-level costs, cannot filter by VPC ID.
|
564
|
+
|
565
|
+
**Explanation**:
|
566
|
+
|
567
|
+
AWS Cost Explorer API does **not** support filtering by VPC ID. The framework uses:
|
568
|
+
|
569
|
+
1. **Account-level cost aggregation**: Total costs for entire AWS account
|
570
|
+
2. **Service-based filtering**: Costs grouped by AWS service (EC2, VPC, ELB, etc.)
|
571
|
+
3. **Conservative attribution methodology**: Infer VPC-specific costs from service patterns
|
572
|
+
|
573
|
+
**Attribution Methodology**:
|
574
|
+
|
575
|
+
| Service Category | Attribution % | Confidence | Logic |
|
576
|
+
|------------------|---------------|------------|-------|
|
577
|
+
| **VPC-specific** (Amazon VPC, PrivateLink) | 100% | HIGH (95%) | Directly attributable to VPC |
|
578
|
+
| **VPC-related** (EC2, ELB, Lambda) | 70% | MEDIUM (85%) | Likely VPC-related |
|
579
|
+
| **Other services** (S3, DynamoDB, etc.) | 30% | LOW (<85%) | May be VPC-related |
|
580
|
+
|
581
|
+
**Solution**: Results are lower-bound estimates. Review `Service_Analysis` column in CSV for breakdown.
|
582
|
+
|
583
|
+
---
|
584
|
+
|
585
|
+
#### Issue: Cost Explorer Data Retention Limit
|
586
|
+
|
587
|
+
**Error**:
|
588
|
+
```
|
589
|
+
ERROR: Cost data not available for date 2024-06-15
|
590
|
+
Cost Explorer retention: 13 months (395 days)
|
591
|
+
```
|
592
|
+
|
593
|
+
**Root Cause**: VPC deletion date older than Cost Explorer retention window.
|
594
|
+
|
595
|
+
**Cost Explorer Retention**: 13 months (395 days) from current date
|
596
|
+
|
597
|
+
**Solution**:
|
598
|
+
|
599
|
+
**Check Deletion Date**:
|
600
|
+
```bash
|
601
|
+
# Calculate days since deletion
|
602
|
+
deletion_date="2024-06-15"
|
603
|
+
current_date=$(date +%Y-%m-%d)
|
604
|
+
days_diff=$(( ($(date -jf "%Y-%m-%d" "$current_date" +%s) - $(date -jf "%Y-%m-%d" "$deletion_date" +%s)) / 86400 ))
|
605
|
+
|
606
|
+
echo "Days since deletion: $days_diff"
|
607
|
+
echo "Cost Explorer retention: 395 days"
|
608
|
+
|
609
|
+
if [ $days_diff -gt 395 ]; then
|
610
|
+
echo "ERROR: Deletion date too old for Cost Explorer"
|
611
|
+
else
|
612
|
+
echo "OK: Within Cost Explorer retention window"
|
613
|
+
fi
|
614
|
+
```
|
615
|
+
|
616
|
+
**Alternative Data Sources**:
|
617
|
+
- AWS Cost and Usage Reports (CUR) - 12-month+ retention
|
618
|
+
- CloudWatch Metrics - 15-month retention
|
619
|
+
- S3 exported billing reports
|
620
|
+
|
621
|
+
---
|
622
|
+
|
623
|
+
#### Issue: No Post-Deletion Data Available
|
624
|
+
|
625
|
+
**Error**:
|
626
|
+
```
|
627
|
+
WARNING: No post-deletion data available for vpc-abc123
|
628
|
+
VPC deleted 5 days ago, framework requires 30 days post-deletion
|
629
|
+
```
|
630
|
+
|
631
|
+
**Root Cause**: VPC deleted too recently for post-deletion analysis.
|
632
|
+
|
633
|
+
**Post-Deletion Requirements**:
|
634
|
+
- Default: 30 days of post-deletion data
|
635
|
+
- Minimum: 7 days for initial analysis
|
636
|
+
|
637
|
+
**Solution Options**:
|
638
|
+
|
639
|
+
**Option 1**: Adjust config to use fewer post-deletion days:
|
640
|
+
```yaml
|
641
|
+
cost_explorer_config:
|
642
|
+
post_deletion_validation:
|
643
|
+
granularity_daily: "DAILY"
|
644
|
+
days_after_deletion: 7 # Reduced from 30
|
645
|
+
```
|
646
|
+
|
647
|
+
**Option 2**: Wait until sufficient post-deletion data available.
|
648
|
+
|
649
|
+
**Option 3**: Run preliminary analysis, re-run after 30 days:
|
650
|
+
```bash
|
651
|
+
# Preliminary analysis (7 days post-deletion)
|
652
|
+
python3 execute_cost_queries_boto3.py --config ../config/recent_deletion_config.yaml
|
653
|
+
|
654
|
+
# Re-run after 30 days (more accurate)
|
655
|
+
python3 execute_cost_queries_boto3.py --config ../config/recent_deletion_config.yaml
|
656
|
+
```
|
657
|
+
|
658
|
+
---
|
659
|
+
|
660
|
+
#### Issue: Cost Explorer Rate Limiting
|
661
|
+
|
662
|
+
**Error**:
|
663
|
+
```
|
664
|
+
ERROR: ThrottlingException - Rate exceeded for Cost Explorer API
|
665
|
+
```
|
666
|
+
|
667
|
+
**Root Cause**: Exceeded AWS Cost Explorer API rate limit (~5 requests/second).
|
668
|
+
|
669
|
+
**Framework Rate Limiting**: 0.3 seconds between queries (default).
|
670
|
+
|
671
|
+
**Solution**:
|
672
|
+
|
673
|
+
**Option 1**: Framework automatically handles rate limiting with delays.
|
674
|
+
|
675
|
+
**Option 2**: Increase delay in code:
|
676
|
+
```python
|
677
|
+
# In execute_cost_queries_boto3.py
|
678
|
+
RATE_LIMIT_DELAY = 0.5 # Increase from 0.3 to 0.5 seconds
|
679
|
+
```
|
680
|
+
|
681
|
+
**Option 3**: Retry after delay:
|
682
|
+
```bash
|
683
|
+
# If execution fails due to rate limiting
|
684
|
+
sleep 60 # Wait 1 minute
|
685
|
+
./run_vpc_savings_analysis.sh ../config/aws25_campaign_config.yaml
|
686
|
+
```
|
687
|
+
|
688
|
+
---
|
689
|
+
|
690
|
+
### Low Confidence Results
|
691
|
+
|
692
|
+
#### Issue: All VPCs Marked LOW Confidence (<85%)
|
693
|
+
|
694
|
+
**Symptom**: All VPCs in CSV have `LOW (<85%)` confidence level.
|
695
|
+
|
696
|
+
**Root Cause**: Multi-VPC accounts or increased post-deletion activity.
|
697
|
+
|
698
|
+
**Common Scenarios**:
|
699
|
+
|
700
|
+
1. **Multi-VPC Account**: Account has/had multiple VPCs, difficult to attribute costs to specific VPC
|
701
|
+
2. **Post-Deletion Activity Increase**: New infrastructure provisioned after VPC deletion
|
702
|
+
3. **Baseline Variability**: High cost fluctuation during pre-deletion period
|
703
|
+
|
704
|
+
**Review Notes Column**:
|
705
|
+
```csv
|
706
|
+
VPC_ID,Confidence_Level,Notes
|
707
|
+
vpc-abc123,LOW (<85%),"Multi-VPC account, other VPCs active during baseline"
|
708
|
+
vpc-def456,LOW (<85%),"Post-deletion costs increased (new EC2 instances launched)"
|
709
|
+
vpc-ghi789,LOW (<85%),"High baseline variability, seasonality detected"
|
710
|
+
```
|
711
|
+
|
712
|
+
**Solution Options**:
|
713
|
+
|
714
|
+
**Option 1**: Accept LOW confidence as lower-bound estimate.
|
715
|
+
|
716
|
+
**Option 2**: Cross-validate with CloudWatch metrics:
|
717
|
+
```bash
|
718
|
+
# Check EC2 instance count trend
|
719
|
+
AWS_PROFILE=your-profile aws cloudwatch get-metric-statistics \
|
720
|
+
--namespace AWS/EC2 \
|
721
|
+
--metric-name InstanceCount \
|
722
|
+
--start-time 2025-07-01T00:00:00Z \
|
723
|
+
--end-time 2025-10-01T00:00:00Z \
|
724
|
+
--period 86400 \
|
725
|
+
--statistics Average
|
726
|
+
```
|
727
|
+
|
728
|
+
**Option 3**: Manual validation with billing team for specific services.
|
729
|
+
|
730
|
+
---
|
731
|
+
|
732
|
+
#### Issue: VPC Deletion Savings Negative
|
733
|
+
|
734
|
+
**Symptom**: `Monthly_Savings_Realized: -$500.00` (negative savings).
|
735
|
+
|
736
|
+
**Root Cause**: Costs increased after VPC deletion.
|
737
|
+
|
738
|
+
**Common Scenarios**:
|
739
|
+
|
740
|
+
1. **New Infrastructure**: New resources provisioned post-deletion
|
741
|
+
2. **Cost Migration**: Costs migrated to other VPCs/accounts
|
742
|
+
3. **Baseline Noise**: Pre-deletion baseline was unusually low
|
743
|
+
|
744
|
+
**Framework Logic**: Reports negative savings (no zero-clamping).
|
745
|
+
|
746
|
+
**CSV Example**:
|
747
|
+
```csv
|
748
|
+
VPC_ID,Pre_Deletion_Monthly_Avg,Post_Deletion_Monthly_Avg,Monthly_Savings_Realized,Notes
|
749
|
+
vpc-abc123,$1000.00,$1500.00,-$500.00,"Costs increased post-deletion, new EC2 instances"
|
750
|
+
```
|
751
|
+
|
752
|
+
**Solution**:
|
753
|
+
|
754
|
+
1. **Review Service_Analysis Column**: Identify which services increased.
|
755
|
+
2. **Check CloudTrail for New Resources**: Post-deletion resource creation.
|
756
|
+
3. **Exclude from Savings Report**: Negative savings indicate no VPC-related savings.
|
757
|
+
|
758
|
+
---
|
759
|
+
|
760
|
+
### VPC Not Found in Results
|
761
|
+
|
762
|
+
#### Issue: VPC Missing from CSV Output
|
763
|
+
|
764
|
+
**Symptom**: Expected 6 VPCs, only 5 in CSV.
|
765
|
+
|
766
|
+
**Root Cause**: Query failed for specific VPC or cost data unavailable.
|
767
|
+
|
768
|
+
**Solution**:
|
769
|
+
|
770
|
+
**Check Logs/Console Output** for errors:
|
771
|
+
```bash
|
772
|
+
./run_vpc_savings_analysis.sh ../config/aws25_campaign_config.yaml 2>&1 | tee execution.log
|
773
|
+
|
774
|
+
# Search for errors
|
775
|
+
grep -i "error\|warning" execution.log
|
776
|
+
```
|
777
|
+
|
778
|
+
**Check JSON Results**:
|
779
|
+
```bash
|
780
|
+
# View raw Cost Explorer results
|
781
|
+
cat ../artifacts/cost_explorer_results.json | jq '.vpc_queries[] | select(.vpc_id == "vpc-abc123")'
|
782
|
+
```
|
783
|
+
|
784
|
+
**Verify VPC Deletion Date**:
|
785
|
+
```bash
|
786
|
+
# Query CloudTrail for exact deletion event
|
787
|
+
AWS_PROFILE=your-profile aws cloudtrail lookup-events \
|
788
|
+
--lookup-attributes AttributeKey=ResourceName,AttributeValue=vpc-abc123
|
789
|
+
```
|
790
|
+
|
791
|
+
---
|
792
|
+
|
793
|
+
### Common Error Messages Reference
|
794
|
+
|
795
|
+
| Error Message | Cause | Solution |
|
796
|
+
|---------------|-------|----------|
|
797
|
+
| `AccessDeniedException` | No Cost Explorer permissions | Add IAM policy with ce:GetCostAndUsage |
|
798
|
+
| `NoCredentialsError` | AWS credentials not configured | Configure AWS profile |
|
799
|
+
| `InvalidVpcId` | VPC ID format invalid | Use vpc-* format |
|
800
|
+
| `ThrottlingException` | API rate limit exceeded | Framework retries automatically |
|
801
|
+
| `ValidationError` | YAML schema validation failed | Check required fields |
|
802
|
+
| `ExpiredTokenException` | STS credentials expired | Re-authenticate |
|
803
|
+
|
804
|
+
---
|
805
|
+
|
806
|
+
## Configuration Reference
|
807
|
+
|
808
|
+
### CLI Parameters
|
809
|
+
|
810
|
+
#### All Scripts Accept
|
811
|
+
|
812
|
+
| Parameter | Description | Default |
|
813
|
+
|-----------|-------------|---------|
|
814
|
+
| `--config` | Path to campaign config YAML | `../config/aws25_campaign_config.yaml` |
|
815
|
+
| `--profile` | AWS profile override | From config `aws_billing_profile` |
|
816
|
+
| `--output-dir` | Output directory override | `../artifacts/` |
|
817
|
+
|
818
|
+
#### Script-Specific Parameters
|
819
|
+
|
820
|
+
**execute_cost_queries_boto3.py**:
|
821
|
+
- `--skip-queries`: Skip query execution, analyze existing results
|
822
|
+
|
823
|
+
**run_vpc_savings_analysis.sh**:
|
824
|
+
- First argument: Config file path (optional)
|
825
|
+
- Second argument: AWS profile override (optional)
|
826
|
+
|
827
|
+
---
|
828
|
+
|
829
|
+
### Advanced Configuration Examples
|
830
|
+
|
831
|
+
#### Custom Attribution Rules
|
832
|
+
|
833
|
+
Fine-tune confidence levels and attribution percentages:
|
834
|
+
|
835
|
+
```yaml
|
836
|
+
attribution_rules:
|
837
|
+
vpc_specific_services:
|
838
|
+
confidence_level: "HIGH (98%)" # Custom confidence
|
839
|
+
attribution_percentage: 95 # Conservative 95%
|
840
|
+
service_patterns:
|
841
|
+
- "Amazon Virtual Private Cloud"
|
842
|
+
- "Amazon VPC"
|
843
|
+
- "AWS PrivateLink"
|
844
|
+
- "VPC Endpoint" # Add custom patterns
|
845
|
+
```
|
846
|
+
|
847
|
+
#### Custom Output Columns
|
848
|
+
|
849
|
+
Customize CSV output columns:
|
850
|
+
|
851
|
+
```yaml
|
852
|
+
output_config:
|
853
|
+
csv_columns:
|
854
|
+
- "VPC_ID"
|
855
|
+
- "Account_ID"
|
856
|
+
- "Region" # Add region
|
857
|
+
- "Deletion_Principal" # Add who deleted
|
858
|
+
- "Monthly_Savings_Realized"
|
859
|
+
- "Annual_Savings_Realized"
|
860
|
+
- "Confidence_Level"
|
861
|
+
- "Service_Analysis" # Add detailed breakdown
|
862
|
+
```
|
863
|
+
|
864
|
+
---
|
865
|
+
|
249
866
|
**Optimization Recommendations**:
|
250
867
|
```
|
251
868
|
╭─ VPC Optimization Recommendations ─╮
|
runbooks/vpc/__init__.py
CHANGED
@@ -23,8 +23,14 @@ from .manager_interface import BusinessRecommendation, ManagerDashboardConfig, V
|
|
23
23
|
from .networking_wrapper import VPCNetworkingWrapper
|
24
24
|
from .rich_formatters import display_cost_table, display_heatmap, display_optimization_recommendations
|
25
25
|
from .vpc_cleanup_integration import VPCCleanupFramework, VPCCleanupCandidate, VPCCleanupRisk, VPCCleanupPhase
|
26
|
-
from .cleanup_wrapper import
|
26
|
+
from .cleanup_wrapper import (
|
27
|
+
VPCCleanupCLI,
|
28
|
+
analyze_cleanup_candidates,
|
29
|
+
validate_cleanup_safety,
|
30
|
+
generate_business_report,
|
31
|
+
)
|
27
32
|
from .runbooks_adapter import RunbooksAdapter
|
33
|
+
from .nat_gateway_optimizer import NATGatewayOptimizer
|
28
34
|
|
29
35
|
__all__ = [
|
30
36
|
"VPCNetworkingWrapper",
|
@@ -45,6 +51,7 @@ __all__ = [
|
|
45
51
|
"validate_cleanup_safety",
|
46
52
|
"generate_business_report",
|
47
53
|
"RunbooksAdapter",
|
54
|
+
"NATGatewayOptimizer",
|
48
55
|
]
|
49
56
|
|
50
57
|
# Import centralized version from main runbooks package
|