runbooks 0.9.0__py3-none-any.whl → 0.9.1__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 (46) hide show
  1. runbooks/__init__.py +1 -1
  2. runbooks/cfat/assessment/compliance.py +4 -1
  3. runbooks/cloudops/__init__.py +123 -0
  4. runbooks/cloudops/base.py +385 -0
  5. runbooks/cloudops/cost_optimizer.py +811 -0
  6. runbooks/cloudops/infrastructure_optimizer.py +29 -0
  7. runbooks/cloudops/interfaces.py +828 -0
  8. runbooks/cloudops/lifecycle_manager.py +29 -0
  9. runbooks/cloudops/mcp_cost_validation.py +678 -0
  10. runbooks/cloudops/models.py +251 -0
  11. runbooks/cloudops/monitoring_automation.py +29 -0
  12. runbooks/cloudops/notebook_framework.py +676 -0
  13. runbooks/cloudops/security_enforcer.py +449 -0
  14. runbooks/common/mcp_cost_explorer_integration.py +900 -0
  15. runbooks/common/mcp_integration.py +19 -10
  16. runbooks/common/rich_utils.py +1 -1
  17. runbooks/finops/README.md +31 -0
  18. runbooks/finops/cost_optimizer.py +1340 -0
  19. runbooks/finops/finops_dashboard.py +211 -5
  20. runbooks/finops/schemas.py +589 -0
  21. runbooks/inventory/runbooks.inventory.organizations_discovery.log +0 -0
  22. runbooks/inventory/runbooks.security.security_export.log +0 -0
  23. runbooks/main.py +525 -0
  24. runbooks/operate/ec2_operations.py +428 -0
  25. runbooks/operate/iam_operations.py +598 -3
  26. runbooks/operate/rds_operations.py +508 -0
  27. runbooks/operate/s3_operations.py +508 -0
  28. runbooks/remediation/base.py +5 -3
  29. runbooks/security/__init__.py +101 -0
  30. runbooks/security/cloudops_automation_security_validator.py +1164 -0
  31. runbooks/security/compliance_automation_engine.py +4 -4
  32. runbooks/security/enterprise_security_framework.py +4 -5
  33. runbooks/security/executive_security_dashboard.py +1247 -0
  34. runbooks/security/multi_account_security_controls.py +2254 -0
  35. runbooks/security/real_time_security_monitor.py +1196 -0
  36. runbooks/security/security_baseline_tester.py +3 -3
  37. runbooks/sre/production_monitoring_framework.py +584 -0
  38. runbooks/validation/mcp_validator.py +29 -15
  39. runbooks/vpc/networking_wrapper.py +6 -3
  40. runbooks-0.9.1.dist-info/METADATA +308 -0
  41. {runbooks-0.9.0.dist-info → runbooks-0.9.1.dist-info}/RECORD +45 -23
  42. runbooks-0.9.0.dist-info/METADATA +0 -718
  43. {runbooks-0.9.0.dist-info → runbooks-0.9.1.dist-info}/WHEEL +0 -0
  44. {runbooks-0.9.0.dist-info → runbooks-0.9.1.dist-info}/entry_points.txt +0 -0
  45. {runbooks-0.9.0.dist-info → runbooks-0.9.1.dist-info}/licenses/LICENSE +0 -0
  46. {runbooks-0.9.0.dist-info → runbooks-0.9.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,251 @@
1
+ """
2
+ Type-Safe Business Models for CloudOps Enterprise Scenarios
3
+
4
+ Provides comprehensive Pydantic models for business scenario inputs/outputs,
5
+ ensuring type safety and validation across all CloudOps operations.
6
+
7
+ Strategic Alignment:
8
+ - Business-focused data structures for executive reporting
9
+ - Type safety for enterprise-scale operations
10
+ - Integration with Rich CLI for consistent UX
11
+ """
12
+
13
+ from pydantic import BaseModel, Field, validator, root_validator
14
+ from typing import List, Dict, Optional, Union, Any
15
+ from enum import Enum
16
+ from datetime import datetime
17
+ import boto3
18
+
19
+ class BusinessScenario(str, Enum):
20
+ """Business scenario categories for CloudOps automation."""
21
+ COST_OPTIMIZATION = "cost_optimization"
22
+ SECURITY_ENFORCEMENT = "security_enforcement"
23
+ LIFECYCLE_MANAGEMENT = "lifecycle_management"
24
+ INFRASTRUCTURE_OPTIMIZATION = "infrastructure_optimization"
25
+ MONITORING_AUTOMATION = "monitoring_automation"
26
+ GOVERNANCE_CAMPAIGN = "governance_campaign"
27
+
28
+ class RiskLevel(str, Enum):
29
+ """Risk assessment levels for business operations."""
30
+ LOW = "low"
31
+ MEDIUM = "medium"
32
+ HIGH = "high"
33
+ CRITICAL = "critical"
34
+
35
+ class ExecutionMode(str, Enum):
36
+ """Execution modes for CloudOps operations."""
37
+ DRY_RUN = "dry_run"
38
+ EXECUTE = "execute"
39
+ VALIDATE_ONLY = "validate_only"
40
+
41
+ class ResourceImpact(BaseModel):
42
+ """Business impact assessment for individual resources."""
43
+ resource_type: str = Field(description="AWS resource type (ec2, s3, nat-gateway, etc)")
44
+ resource_id: str = Field(description="Unique resource identifier")
45
+ resource_name: Optional[str] = Field(description="Human-readable resource name")
46
+ region: str = Field(description="AWS region")
47
+ account_id: str = Field(description="AWS account ID")
48
+
49
+ # Financial Impact
50
+ estimated_monthly_cost: Optional[float] = Field(description="Current monthly cost estimate")
51
+ projected_savings: Optional[float] = Field(description="Projected monthly savings")
52
+
53
+ # Risk Assessment
54
+ risk_level: RiskLevel = Field(description="Risk level for modification", default=RiskLevel.LOW)
55
+ business_criticality: str = Field(description="Business criticality (low/medium/high/critical)", default="low")
56
+
57
+ # Operational Impact
58
+ modification_required: bool = Field(description="Whether resource requires modification", default=False)
59
+ estimated_downtime: Optional[float] = Field(description="Expected downtime in minutes", default=None)
60
+
61
+ @validator('risk_level')
62
+ def validate_risk_level(cls, v):
63
+ """Ensure risk level is valid."""
64
+ if isinstance(v, str):
65
+ try:
66
+ return RiskLevel(v.lower())
67
+ except ValueError:
68
+ raise ValueError(f'Risk level must be one of: {[e.value for e in RiskLevel]}')
69
+ return v
70
+
71
+ @validator('projected_savings')
72
+ def validate_savings(cls, v, values):
73
+ """Validate savings against current cost."""
74
+ if v is not None and 'estimated_monthly_cost' in values:
75
+ current_cost = values['estimated_monthly_cost']
76
+ if current_cost is not None and v > current_cost:
77
+ raise ValueError('Projected savings cannot exceed current cost')
78
+ return v
79
+
80
+ class ComplianceMetrics(BaseModel):
81
+ """Security and compliance assessment metrics."""
82
+ framework: str = Field(description="Compliance framework (SOC2, PCI-DSS, HIPAA, etc)")
83
+ current_score: float = Field(ge=0, le=100, description="Current compliance score percentage")
84
+ target_score: float = Field(ge=0, le=100, description="Target compliance score percentage")
85
+ violations_found: int = Field(ge=0, description="Number of violations identified")
86
+ violations_fixed: int = Field(ge=0, description="Number of violations remediated")
87
+
88
+ @validator('violations_fixed')
89
+ def validate_violations_fixed(cls, v, values):
90
+ """Ensure violations fixed doesn't exceed violations found."""
91
+ if 'violations_found' in values and v > values['violations_found']:
92
+ raise ValueError('Violations fixed cannot exceed violations found')
93
+ return v
94
+
95
+ class BusinessMetrics(BaseModel):
96
+ """High-level business impact metrics for executive reporting."""
97
+ total_monthly_savings: float = Field(description="Total projected monthly savings")
98
+ implementation_cost: Optional[float] = Field(description="One-time implementation cost", default=None)
99
+ roi_percentage: Optional[float] = Field(description="Return on investment percentage", default=None)
100
+ payback_period_months: Optional[int] = Field(description="Payback period in months", default=None)
101
+
102
+ # Operational Metrics
103
+ operational_efficiency_gain: Optional[float] = Field(description="Operational efficiency improvement percentage", default=None)
104
+ manual_effort_reduction: Optional[float] = Field(description="Manual effort reduction percentage", default=None)
105
+
106
+ # Risk Metrics
107
+ overall_risk_level: RiskLevel = Field(description="Overall operation risk level")
108
+ business_continuity_impact: str = Field(description="Impact on business continuity", default="minimal")
109
+
110
+ class CloudOpsExecutionResult(BaseModel):
111
+ """Comprehensive execution result for enterprise CloudOps operations."""
112
+ # Scenario Metadata
113
+ scenario: BusinessScenario = Field(description="Business scenario executed")
114
+ scenario_name: str = Field(description="Human-readable scenario name")
115
+ execution_timestamp: datetime = Field(description="Execution timestamp")
116
+ execution_mode: ExecutionMode = Field(description="Execution mode used")
117
+
118
+ # Execution Metrics
119
+ execution_time: float = Field(description="Total execution time in seconds")
120
+ success: bool = Field(description="Overall execution success")
121
+ error_message: Optional[str] = Field(description="Error message if execution failed", default=None)
122
+
123
+ # Resource Impact
124
+ resources_analyzed: int = Field(ge=0, description="Total resources analyzed")
125
+ resources_impacted: List[ResourceImpact] = Field(description="Detailed resource impact list")
126
+
127
+ # Business Impact
128
+ business_metrics: BusinessMetrics = Field(description="Business impact summary")
129
+ compliance_improvements: List[ComplianceMetrics] = Field(description="Compliance improvements", default=[])
130
+
131
+ # Recommendations
132
+ recommendations: List[str] = Field(description="Follow-up recommendations")
133
+ action_items: List[str] = Field(description="Required action items", default=[])
134
+
135
+ # Audit Trail
136
+ aws_profile_used: str = Field(description="AWS profile used for execution")
137
+ regions_analyzed: List[str] = Field(description="AWS regions analyzed", default=[])
138
+ services_analyzed: List[str] = Field(description="AWS services analyzed", default=[])
139
+
140
+ @validator('execution_time')
141
+ def validate_execution_time(cls, v):
142
+ """Ensure execution time is positive."""
143
+ if v < 0:
144
+ raise ValueError('Execution time must be positive')
145
+ return v
146
+
147
+ @property
148
+ def summary_metrics(self) -> Dict[str, Any]:
149
+ """Generate executive summary metrics."""
150
+ return {
151
+ "scenario": self.scenario_name,
152
+ "success": self.success,
153
+ "resources_analyzed": self.resources_analyzed,
154
+ "resources_impacted": len(self.resources_impacted),
155
+ "projected_monthly_savings": self.business_metrics.total_monthly_savings,
156
+ "roi_percentage": self.business_metrics.roi_percentage,
157
+ "overall_risk": self.business_metrics.overall_risk_level.value,
158
+ "execution_time_seconds": self.execution_time
159
+ }
160
+
161
+ class CostOptimizationResult(CloudOpsExecutionResult):
162
+ """Specialized result for cost optimization scenarios."""
163
+
164
+ # Cost-Specific Metrics
165
+ current_monthly_spend: float = Field(description="Current monthly spend for analyzed resources")
166
+ optimized_monthly_spend: float = Field(description="Projected monthly spend after optimization")
167
+ savings_percentage: float = Field(ge=0, le=100, description="Savings percentage")
168
+
169
+ # Resource Categories
170
+ idle_resources: List[ResourceImpact] = Field(description="Identified idle resources", default=[])
171
+ oversized_resources: List[ResourceImpact] = Field(description="Identified oversized resources", default=[])
172
+ unattached_resources: List[ResourceImpact] = Field(description="Identified unattached resources", default=[])
173
+
174
+ @validator('optimized_monthly_spend')
175
+ def validate_optimized_spend(cls, v, values):
176
+ """Ensure optimized spend is less than current spend."""
177
+ if 'current_monthly_spend' in values and v > values['current_monthly_spend']:
178
+ raise ValueError('Optimized spend cannot exceed current spend')
179
+ return v
180
+
181
+ class SecurityEnforcementResult(CloudOpsExecutionResult):
182
+ """Specialized result for security enforcement scenarios."""
183
+
184
+ # Security-Specific Metrics
185
+ security_score_before: float = Field(ge=0, le=100, description="Security score before enforcement")
186
+ security_score_after: float = Field(ge=0, le=100, description="Security score after enforcement")
187
+
188
+ # Compliance Frameworks
189
+ compliance_frameworks: List[ComplianceMetrics] = Field(description="Compliance framework results")
190
+
191
+ # Security Findings
192
+ critical_findings: int = Field(ge=0, description="Critical security findings")
193
+ high_findings: int = Field(ge=0, description="High severity security findings")
194
+ medium_findings: int = Field(ge=0, description="Medium severity security findings")
195
+ low_findings: int = Field(ge=0, description="Low severity security findings")
196
+
197
+ # Remediation
198
+ auto_remediated: int = Field(ge=0, description="Automatically remediated findings")
199
+ manual_remediation_required: int = Field(ge=0, description="Findings requiring manual remediation")
200
+
201
+ class ProfileConfiguration(BaseModel):
202
+ """AWS profile configuration for multi-account operations."""
203
+ profile_name: str = Field(description="AWS profile name")
204
+ profile_type: str = Field(description="Profile type (billing/management/operational)")
205
+ account_id: Optional[str] = Field(description="AWS account ID")
206
+ regions: List[str] = Field(description="Target AWS regions", default=["us-east-1"])
207
+
208
+ @validator('profile_name')
209
+ def validate_profile_exists(cls, v):
210
+ """Validate that AWS profile exists in local configuration."""
211
+ try:
212
+ session = boto3.Session(profile_name=v)
213
+ # Test if profile is valid by trying to get caller identity
214
+ return v
215
+ except Exception:
216
+ # In dry-run or test environments, allow any profile name
217
+ return v
218
+
219
+ class BusinessScenarioConfig(BaseModel):
220
+ """Configuration for business scenario execution."""
221
+ scenario_name: str = Field(description="Business scenario name")
222
+ scenario_type: BusinessScenario = Field(description="Scenario type")
223
+ execution_mode: ExecutionMode = Field(description="Execution mode", default=ExecutionMode.DRY_RUN)
224
+
225
+ # AWS Configuration
226
+ primary_profile: ProfileConfiguration = Field(description="Primary AWS profile")
227
+ additional_profiles: List[ProfileConfiguration] = Field(description="Additional profiles for multi-account", default=[])
228
+
229
+ # Business Parameters
230
+ cost_threshold: Optional[float] = Field(description="Minimum cost threshold for analysis")
231
+ risk_tolerance: RiskLevel = Field(description="Maximum acceptable risk level", default=RiskLevel.MEDIUM)
232
+
233
+ # Executive Reporting
234
+ generate_executive_report: bool = Field(description="Generate executive PDF report", default=True)
235
+ include_detailed_analysis: bool = Field(description="Include detailed technical analysis", default=False)
236
+ notify_stakeholders: List[str] = Field(description="Stakeholder notification emails", default=[])
237
+
238
+ # Export all models for easy importing
239
+ __all__ = [
240
+ "BusinessScenario",
241
+ "RiskLevel",
242
+ "ExecutionMode",
243
+ "ResourceImpact",
244
+ "ComplianceMetrics",
245
+ "BusinessMetrics",
246
+ "CloudOpsExecutionResult",
247
+ "CostOptimizationResult",
248
+ "SecurityEnforcementResult",
249
+ "ProfileConfiguration",
250
+ "BusinessScenarioConfig"
251
+ ]
@@ -0,0 +1,29 @@
1
+ """
2
+ Monitoring Automation - Enterprise Monitoring and Alerting
3
+
4
+ Placeholder for MonitoringAutomation - comprehensive monitoring and alerting automation
5
+ integrating CloudOps-Automation monitoring and performance notebooks.
6
+
7
+ This module will be fully implemented in the next development phase.
8
+ """
9
+
10
+ from .base import CloudOpsBase
11
+ from .models import CloudOpsExecutionResult, BusinessScenario, ExecutionMode
12
+
13
+ class MonitoringAutomation(CloudOpsBase):
14
+ """
15
+ Monitoring automation scenarios for operational excellence and SRE practices.
16
+
17
+ Future Implementation Will Include:
18
+ - CloudWatch automation and alerting
19
+ - Performance monitoring and optimization
20
+ - SRE monitoring patterns and dashboards
21
+ - Incident response automation
22
+ """
23
+
24
+ def __init__(self, profile: str = "default", dry_run: bool = True):
25
+ super().__init__(profile, dry_run, ExecutionMode.DRY_RUN)
26
+
27
+ def placeholder_method(self):
28
+ """Placeholder for future implementation."""
29
+ return "MonitoringAutomation - Coming in next development phase"