runbooks 0.7.7__py3-none-any.whl → 0.9.0__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.
Files changed (157) hide show
  1. runbooks/__init__.py +1 -1
  2. runbooks/base.py +2 -2
  3. runbooks/cfat/README.md +12 -1
  4. runbooks/cfat/__init__.py +8 -4
  5. runbooks/cfat/assessment/collectors.py +171 -14
  6. runbooks/cfat/assessment/compliance.py +546 -522
  7. runbooks/cfat/assessment/runner.py +129 -10
  8. runbooks/cfat/models.py +6 -2
  9. runbooks/common/__init__.py +152 -0
  10. runbooks/common/accuracy_validator.py +1039 -0
  11. runbooks/common/context_logger.py +440 -0
  12. runbooks/common/cross_module_integration.py +594 -0
  13. runbooks/common/enhanced_exception_handler.py +1108 -0
  14. runbooks/common/enterprise_audit_integration.py +634 -0
  15. runbooks/common/logger.py +14 -0
  16. runbooks/common/mcp_integration.py +539 -0
  17. runbooks/common/performance_monitor.py +387 -0
  18. runbooks/common/profile_utils.py +216 -0
  19. runbooks/common/rich_utils.py +622 -0
  20. runbooks/enterprise/__init__.py +68 -0
  21. runbooks/enterprise/error_handling.py +411 -0
  22. runbooks/enterprise/logging.py +439 -0
  23. runbooks/enterprise/multi_tenant.py +583 -0
  24. runbooks/feedback/user_feedback_collector.py +440 -0
  25. runbooks/finops/README.md +129 -14
  26. runbooks/finops/__init__.py +22 -3
  27. runbooks/finops/account_resolver.py +279 -0
  28. runbooks/finops/accuracy_cross_validator.py +638 -0
  29. runbooks/finops/aws_client.py +721 -36
  30. runbooks/finops/budget_integration.py +313 -0
  31. runbooks/finops/cli.py +90 -33
  32. runbooks/finops/cost_processor.py +211 -37
  33. runbooks/finops/dashboard_router.py +900 -0
  34. runbooks/finops/dashboard_runner.py +1334 -399
  35. runbooks/finops/embedded_mcp_validator.py +288 -0
  36. runbooks/finops/enhanced_dashboard_runner.py +526 -0
  37. runbooks/finops/enhanced_progress.py +327 -0
  38. runbooks/finops/enhanced_trend_visualization.py +423 -0
  39. runbooks/finops/finops_dashboard.py +41 -0
  40. runbooks/finops/helpers.py +639 -323
  41. runbooks/finops/iam_guidance.py +400 -0
  42. runbooks/finops/markdown_exporter.py +466 -0
  43. runbooks/finops/multi_dashboard.py +1502 -0
  44. runbooks/finops/optimizer.py +396 -395
  45. runbooks/finops/profile_processor.py +2 -2
  46. runbooks/finops/runbooks.inventory.organizations_discovery.log +0 -0
  47. runbooks/finops/runbooks.security.report_generator.log +0 -0
  48. runbooks/finops/runbooks.security.run_script.log +0 -0
  49. runbooks/finops/runbooks.security.security_export.log +0 -0
  50. runbooks/finops/service_mapping.py +195 -0
  51. runbooks/finops/single_dashboard.py +710 -0
  52. runbooks/finops/tests/__init__.py +19 -0
  53. runbooks/finops/tests/results_test_finops_dashboard.xml +1 -0
  54. runbooks/finops/tests/run_comprehensive_tests.py +421 -0
  55. runbooks/finops/tests/run_tests.py +305 -0
  56. runbooks/finops/tests/test_finops_dashboard.py +705 -0
  57. runbooks/finops/tests/test_integration.py +477 -0
  58. runbooks/finops/tests/test_performance.py +380 -0
  59. runbooks/finops/tests/test_performance_benchmarks.py +500 -0
  60. runbooks/finops/tests/test_reference_images_validation.py +867 -0
  61. runbooks/finops/tests/test_single_account_features.py +715 -0
  62. runbooks/finops/tests/validate_test_suite.py +220 -0
  63. runbooks/finops/types.py +1 -1
  64. runbooks/hitl/enhanced_workflow_engine.py +725 -0
  65. runbooks/inventory/README.md +12 -1
  66. runbooks/inventory/artifacts/scale-optimize-status.txt +12 -0
  67. runbooks/inventory/collectors/aws_comprehensive.py +192 -185
  68. runbooks/inventory/collectors/enterprise_scale.py +281 -0
  69. runbooks/inventory/core/collector.py +299 -12
  70. runbooks/inventory/list_ec2_instances.py +21 -20
  71. runbooks/inventory/list_ssm_parameters.py +31 -3
  72. runbooks/inventory/organizations_discovery.py +1315 -0
  73. runbooks/inventory/rich_inventory_display.py +360 -0
  74. runbooks/inventory/run_on_multi_accounts.py +32 -16
  75. runbooks/inventory/runbooks.security.report_generator.log +0 -0
  76. runbooks/inventory/runbooks.security.run_script.log +0 -0
  77. runbooks/inventory/vpc_flow_analyzer.py +1030 -0
  78. runbooks/main.py +4171 -1615
  79. runbooks/metrics/dora_metrics_engine.py +1293 -0
  80. runbooks/monitoring/performance_monitor.py +433 -0
  81. runbooks/operate/README.md +394 -0
  82. runbooks/operate/__init__.py +2 -2
  83. runbooks/operate/base.py +291 -11
  84. runbooks/operate/deployment_framework.py +1032 -0
  85. runbooks/operate/deployment_validator.py +853 -0
  86. runbooks/operate/dynamodb_operations.py +10 -6
  87. runbooks/operate/ec2_operations.py +321 -11
  88. runbooks/operate/executive_dashboard.py +779 -0
  89. runbooks/operate/mcp_integration.py +750 -0
  90. runbooks/operate/nat_gateway_operations.py +1120 -0
  91. runbooks/operate/networking_cost_heatmap.py +685 -0
  92. runbooks/operate/privatelink_operations.py +940 -0
  93. runbooks/operate/s3_operations.py +10 -6
  94. runbooks/operate/vpc_endpoints.py +644 -0
  95. runbooks/operate/vpc_operations.py +1038 -0
  96. runbooks/remediation/README.md +489 -13
  97. runbooks/remediation/__init__.py +2 -2
  98. runbooks/remediation/acm_remediation.py +1 -1
  99. runbooks/remediation/base.py +1 -1
  100. runbooks/remediation/cloudtrail_remediation.py +1 -1
  101. runbooks/remediation/cognito_remediation.py +1 -1
  102. runbooks/remediation/commons.py +8 -4
  103. runbooks/remediation/dynamodb_remediation.py +1 -1
  104. runbooks/remediation/ec2_remediation.py +1 -1
  105. runbooks/remediation/ec2_unattached_ebs_volumes.py +1 -1
  106. runbooks/remediation/kms_enable_key_rotation.py +1 -1
  107. runbooks/remediation/kms_remediation.py +1 -1
  108. runbooks/remediation/lambda_remediation.py +1 -1
  109. runbooks/remediation/multi_account.py +1 -1
  110. runbooks/remediation/rds_remediation.py +1 -1
  111. runbooks/remediation/s3_block_public_access.py +1 -1
  112. runbooks/remediation/s3_enable_access_logging.py +1 -1
  113. runbooks/remediation/s3_encryption.py +1 -1
  114. runbooks/remediation/s3_remediation.py +1 -1
  115. runbooks/remediation/vpc_remediation.py +475 -0
  116. runbooks/security/ENTERPRISE_SECURITY_FRAMEWORK.md +506 -0
  117. runbooks/security/README.md +12 -1
  118. runbooks/security/__init__.py +166 -33
  119. runbooks/security/compliance_automation.py +634 -0
  120. runbooks/security/compliance_automation_engine.py +1021 -0
  121. runbooks/security/enterprise_security_framework.py +931 -0
  122. runbooks/security/enterprise_security_policies.json +293 -0
  123. runbooks/security/integration_test_enterprise_security.py +879 -0
  124. runbooks/security/module_security_integrator.py +641 -0
  125. runbooks/security/report_generator.py +10 -0
  126. runbooks/security/run_script.py +27 -5
  127. runbooks/security/security_baseline_tester.py +153 -27
  128. runbooks/security/security_export.py +456 -0
  129. runbooks/sre/README.md +472 -0
  130. runbooks/sre/__init__.py +33 -0
  131. runbooks/sre/mcp_reliability_engine.py +1049 -0
  132. runbooks/sre/performance_optimization_engine.py +1032 -0
  133. runbooks/sre/reliability_monitoring_framework.py +1011 -0
  134. runbooks/validation/__init__.py +10 -0
  135. runbooks/validation/benchmark.py +489 -0
  136. runbooks/validation/cli.py +368 -0
  137. runbooks/validation/mcp_validator.py +797 -0
  138. runbooks/vpc/README.md +478 -0
  139. runbooks/vpc/__init__.py +38 -0
  140. runbooks/vpc/config.py +212 -0
  141. runbooks/vpc/cost_engine.py +347 -0
  142. runbooks/vpc/heatmap_engine.py +605 -0
  143. runbooks/vpc/manager_interface.py +649 -0
  144. runbooks/vpc/networking_wrapper.py +1289 -0
  145. runbooks/vpc/rich_formatters.py +693 -0
  146. runbooks/vpc/tests/__init__.py +5 -0
  147. runbooks/vpc/tests/conftest.py +356 -0
  148. runbooks/vpc/tests/test_cli_integration.py +530 -0
  149. runbooks/vpc/tests/test_config.py +458 -0
  150. runbooks/vpc/tests/test_cost_engine.py +479 -0
  151. runbooks/vpc/tests/test_networking_wrapper.py +512 -0
  152. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/METADATA +175 -65
  153. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/RECORD +157 -60
  154. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/entry_points.txt +1 -1
  155. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/WHEEL +0 -0
  156. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/licenses/LICENSE +0 -0
  157. {runbooks-0.7.7.dist-info → runbooks-0.9.0.dist-info}/top_level.txt +0 -0
runbooks/__init__.py CHANGED
@@ -67,7 +67,7 @@ try:
67
67
  __version__ = _pkg_version("runbooks")
68
68
  except Exception:
69
69
  # Fallback if metadata is unavailable during editable installs
70
- __version__ = "0.7.6"
70
+ __version__ = "0.9.0"
71
71
 
72
72
  # Core module exports
73
73
  from runbooks.config import RunbooksConfig, load_config, save_config
runbooks/base.py CHANGED
@@ -88,8 +88,8 @@ class CloudFoundationsBase(ABC):
88
88
  def _create_session(self) -> boto3.Session:
89
89
  """Create boto3 session with appropriate configuration."""
90
90
  # Use environment variable first, then profile parameter, then default
91
- profile = os.environ.get('AWS_PROFILE') or self.profile
92
-
91
+ profile = os.environ.get("AWS_PROFILE") or self.profile
92
+
93
93
  session_kwargs = {"profile_name": profile}
94
94
  if self.region:
95
95
  session_kwargs["region_name"] = self.region
runbooks/cfat/README.md CHANGED
@@ -1,4 +1,15 @@
1
- # Cloud Foundations Assessment Tool (CFAT)
1
+ # AWS Cloud Foundations Assessment Tool (CLI)
2
+
3
+ The AWS Cloud Foundations Assessment Tool (CFAT) is an enterprise-grade command-line tool for automated discovery and assessment of AWS environments and multi-account architectures. Built with the Rich library for beautiful terminal output, it provides comprehensive evaluation against Cloud Foundations best practices with advanced enterprise features.
4
+
5
+ ## 📈 *cfat-runbooks*.md Enterprise Rollout
6
+
7
+ Following proven **99/100 manager score** success patterns established in FinOps:
8
+
9
+ ### **Rollout Strategy**: Progressive *-runbooks*.md standardization
10
+ - **Phase 1**: CFAT rollout with *cfat-runbooks*.md framework ✅
11
+ - **Integration**: Multi-format reporting with project management export
12
+ - **Enterprise Features**: SOC2, PCI-DSS, HIPAA alignment support
2
13
 
3
14
  **CFAT** is an enterprise-grade, open-source solution designed to provide automated discovery and assessment of AWS environments and multi-account architectures. **Fully integrated with the CloudOps Runbooks CLI**, CFAT offers comprehensive evaluation against Cloud Foundations best practices with advanced enterprise features.
4
15
 
runbooks/cfat/__init__.py CHANGED
@@ -30,11 +30,15 @@ Example:
30
30
  report.to_html("assessment_report.html")
31
31
  report.to_json("findings.json")
32
32
 
33
- print(f"Compliance Score: {report.summary.compliance_score}/100")
34
- print(f"Critical Issues: {report.summary.critical_issues}")
33
+ # Rich console output for better formatting
34
+ from rich.console import Console
35
+ console = Console()
36
+
37
+ console.print(f"[green]Compliance Score: {report.summary.compliance_score}/100[/green]")
38
+ console.print(f"[red]Critical Issues: {report.summary.critical_issues}[/red]")
35
39
  ```
36
40
 
37
- Version: 0.7.6 (Latest with enhanced CLI integration, rust tooling, and modern dependency stack)
41
+ Version: 0.7.8 (Latest with enhanced CLI integration, rust tooling, and modern dependency stack)
38
42
  """
39
43
 
40
44
  # Core assessment engine
@@ -53,7 +57,7 @@ from runbooks.cfat.models import (
53
57
  from runbooks.cfat.runner import AssessmentRunner
54
58
 
55
59
  # Version info
56
- __version__ = "0.7.6"
60
+ __version__ = "0.7.8"
57
61
  __author__ = "CloudOps Runbooks Team"
58
62
 
59
63
  # Public API exports
@@ -66,7 +66,7 @@ class IAMCollector(BaseCollector):
66
66
 
67
67
 
68
68
  class VPCCollector(BaseCollector):
69
- """Virtual Private Cloud resource collector."""
69
+ """Virtual Private Cloud resource collector with NAT Gateway cost optimization integration."""
70
70
 
71
71
  def get_service_name(self) -> str:
72
72
  """Get service name."""
@@ -74,23 +74,180 @@ class VPCCollector(BaseCollector):
74
74
 
75
75
  def collect(self) -> Dict[str, Any]:
76
76
  """
77
- Collect VPC resources for assessment.
77
+ Collect VPC resources for assessment with NAT Gateway cost analysis.
78
78
 
79
79
  Returns:
80
- Dictionary containing VPC resource data
80
+ Dictionary containing VPC resource data including cost optimization insights
81
81
  """
82
- logger.info("Collecting VPC resources...")
82
+ logger.info("Collecting VPC resources with cost optimization analysis...")
83
+
84
+ try:
85
+ ec2_client = self.session.client("ec2", region_name=self.region)
86
+
87
+ # Collect VPCs
88
+ vpcs_response = ec2_client.describe_vpcs()
89
+ vpcs = vpcs_response.get("Vpcs", [])
90
+
91
+ # Collect Subnets
92
+ subnets_response = ec2_client.describe_subnets()
93
+ subnets = subnets_response.get("Subnets", [])
94
+
95
+ # Collect NAT Gateways with cost analysis (GitHub Issue #96)
96
+ nat_gateways_response = ec2_client.describe_nat_gateways()
97
+ nat_gateways = nat_gateways_response.get("NatGateways", [])
98
+
99
+ # Calculate NAT Gateway costs ($45/month per gateway)
100
+ active_nat_gateways = [ng for ng in nat_gateways if ng.get("State") == "available"]
101
+ nat_cost_analysis = {
102
+ "total_nat_gateways": len(active_nat_gateways),
103
+ "estimated_monthly_cost": len(active_nat_gateways) * 45.0,
104
+ "optimization_opportunities": self._analyze_nat_optimization(active_nat_gateways, subnets),
105
+ "cost_alerts": [],
106
+ }
107
+
108
+ if len(active_nat_gateways) > 3:
109
+ nat_cost_analysis["cost_alerts"].append(
110
+ f"HIGH COST: {len(active_nat_gateways)} NAT Gateways detected. "
111
+ f"Monthly cost: ${nat_cost_analysis['estimated_monthly_cost']:,.2f}"
112
+ )
113
+
114
+ # Collect Security Groups
115
+ sg_response = ec2_client.describe_security_groups()
116
+ security_groups = sg_response.get("SecurityGroups", [])
117
+
118
+ # Collect Network ACLs
119
+ nacls_response = ec2_client.describe_network_acls()
120
+ nacls = nacls_response.get("NetworkAcls", [])
121
+
122
+ # Collect Internet Gateways
123
+ igw_response = ec2_client.describe_internet_gateways()
124
+ internet_gateways = igw_response.get("InternetGateways", [])
125
+
126
+ # Collect VPC Flow Logs
127
+ flow_logs_response = ec2_client.describe_flow_logs()
128
+ flow_logs = flow_logs_response.get("FlowLogs", [])
129
+
130
+ # Collect Route Tables for routing analysis
131
+ route_tables_response = ec2_client.describe_route_tables()
132
+ route_tables = route_tables_response.get("RouteTables", [])
133
+
134
+ logger.info(
135
+ f"Collected {len(vpcs)} VPCs, {len(nat_gateways)} NAT Gateways, "
136
+ f"estimated monthly NAT cost: ${nat_cost_analysis['estimated_monthly_cost']:,.2f}"
137
+ )
138
+
139
+ return {
140
+ "vpcs": vpcs,
141
+ "subnets": subnets,
142
+ "nat_gateways": nat_gateways,
143
+ "nat_cost_analysis": nat_cost_analysis, # New: Cost optimization data
144
+ "security_groups": security_groups,
145
+ "nacls": nacls,
146
+ "flow_logs": flow_logs,
147
+ "internet_gateways": internet_gateways,
148
+ "route_tables": route_tables,
149
+ "assessment_metadata": {
150
+ "collector_version": "v0.7.8-vpc-enhanced",
151
+ "github_issue": "#96",
152
+ "cost_optimization_enabled": True,
153
+ },
154
+ }
155
+
156
+ except Exception as e:
157
+ logger.error(f"Failed to collect VPC resources: {e}")
158
+ return {
159
+ "vpcs": [],
160
+ "subnets": [],
161
+ "nat_gateways": [],
162
+ "nat_cost_analysis": {"error": str(e)},
163
+ "security_groups": [],
164
+ "nacls": [],
165
+ "flow_logs": [],
166
+ "internet_gateways": [],
167
+ "route_tables": [],
168
+ "assessment_metadata": {"collector_version": "v0.7.8-vpc-enhanced", "error": str(e)},
169
+ }
170
+
171
+ def _analyze_nat_optimization(self, nat_gateways: List[Dict], subnets: List[Dict]) -> int:
172
+ """
173
+ Analyze NAT Gateway placement for cost optimization opportunities.
83
174
 
84
- # Placeholder implementation
85
- # TODO: Implement actual VPC resource collection
86
- return {
87
- "vpcs": [],
88
- "subnets": [],
89
- "security_groups": [],
90
- "nacls": [],
91
- "flow_logs": [],
92
- "internet_gateways": [],
93
- }
175
+ Args:
176
+ nat_gateways: List of NAT Gateway configurations
177
+ subnets: List of subnet configurations
178
+
179
+ Returns:
180
+ Number of optimization opportunities found
181
+ """
182
+ opportunities = 0
183
+
184
+ # Group NAT Gateways by Availability Zone
185
+ az_nat_count = {}
186
+ for nat in nat_gateways:
187
+ if nat.get("State") == "available":
188
+ subnet_id = nat.get("SubnetId")
189
+ # Find AZ for this subnet
190
+ subnet_az = None
191
+ for subnet in subnets:
192
+ if subnet.get("SubnetId") == subnet_id:
193
+ subnet_az = subnet.get("AvailabilityZone")
194
+ break
195
+
196
+ if subnet_az:
197
+ az_nat_count[subnet_az] = az_nat_count.get(subnet_az, 0) + 1
198
+
199
+ # Check for potential consolidation opportunities
200
+ for az, count in az_nat_count.items():
201
+ if count > 1:
202
+ opportunities += count - 1 # Could potentially consolidate to 1 per AZ
203
+
204
+ return opportunities
205
+
206
+ def run(self) -> "CloudFoundationsResult":
207
+ """
208
+ Run VPC resource collection and return standardized result.
209
+
210
+ Returns:
211
+ CloudFoundationsResult with VPC assessment data including NAT Gateway cost analysis
212
+ """
213
+ try:
214
+ # Collect VPC resources with cost optimization analysis
215
+ vpc_data = self.collect()
216
+
217
+ # Determine success based on data collection
218
+ success = bool(vpc_data) and not vpc_data.get("assessment_metadata", {}).get("error")
219
+
220
+ # Create message with cost insights
221
+ nat_cost_analysis = vpc_data.get("nat_cost_analysis", {})
222
+ total_cost = nat_cost_analysis.get("estimated_monthly_cost", 0)
223
+ total_nats = nat_cost_analysis.get("total_nat_gateways", 0)
224
+
225
+ if success:
226
+ message = (
227
+ f"VPC assessment completed: {len(vpc_data.get('vpcs', []))} VPCs, "
228
+ f"{total_nats} NAT Gateways, estimated monthly NAT cost: ${total_cost:,.2f}"
229
+ )
230
+
231
+ # Add cost alerts to message if present
232
+ cost_alerts = nat_cost_analysis.get("cost_alerts", [])
233
+ if cost_alerts:
234
+ message += f". {len(cost_alerts)} cost optimization opportunities identified"
235
+ else:
236
+ error = vpc_data.get("assessment_metadata", {}).get("error", "Unknown error")
237
+ message = f"VPC assessment failed: {error}"
238
+
239
+ return self.create_result(
240
+ success=success,
241
+ message=message,
242
+ data=vpc_data,
243
+ errors=[vpc_data.get("assessment_metadata", {}).get("error")] if not success else [],
244
+ )
245
+
246
+ except Exception as e:
247
+ logger.error(f"VPC collector run failed: {e}")
248
+ return self.create_result(
249
+ success=False, message=f"VPC assessment failed: {str(e)}", data={}, errors=[str(e)]
250
+ )
94
251
 
95
252
 
96
253
  class CloudTrailCollector(BaseCollector):