cdk-cost-analyzer 0.1.8 → 0.1.10

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.
@@ -2,11 +2,11 @@
2
2
  "entries": {
3
3
  "AmazonS3:EU (Frankfurt):storageClass:General Purpose|volumeType:Standard": {
4
4
  "price": 0.023,
5
- "timestamp": 1768936544693
5
+ "timestamp": 1768990516595
6
6
  },
7
7
  "AmazonS3:invalid-region-123:storageClass:General Purpose|volumeType:Standard": {
8
8
  "price": 0.023,
9
- "timestamp": 1768936544730
9
+ "timestamp": 1768990516633
10
10
  }
11
11
  }
12
12
  }
@@ -0,0 +1,319 @@
1
+ # Design Document: Single Template Cost Analysis
2
+
3
+ ## Overview
4
+
5
+ This design extends the cdk-cost-analyzer tool to support analyzing a single CloudFormation template for estimated monthly costs. The feature leverages the existing pricing service architecture while introducing new components for single template processing and specialized reporting.
6
+
7
+ The solution introduces a new `analyze` CLI command and `analyzeSingleTemplate` API function that processes a single template, calculates costs for all resources, and provides detailed cost breakdowns without requiring a comparison baseline.
8
+
9
+ ## Architecture
10
+
11
+ The single template analysis feature integrates with the existing architecture through these key components:
12
+
13
+ ```mermaid
14
+ graph TB
15
+ CLI[CLI Interface] --> API[API Layer]
16
+ API --> Parser[Template Parser]
17
+ API --> SingleAnalyzer[Single Template Analyzer]
18
+ SingleAnalyzer --> PricingService[Pricing Service]
19
+ SingleAnalyzer --> SingleReporter[Single Template Reporter]
20
+ PricingService --> Calculators[Resource Calculators]
21
+ PricingService --> PricingClient[Pricing Client]
22
+ SingleReporter --> Output[Formatted Output]
23
+
24
+ subgraph "New Components"
25
+ SingleAnalyzer
26
+ SingleReporter
27
+ end
28
+
29
+ subgraph "Existing Components"
30
+ Parser
31
+ PricingService
32
+ Calculators
33
+ PricingClient
34
+ end
35
+ ```
36
+
37
+ The design maintains separation of concerns by:
38
+ - Reusing existing template parsing and pricing calculation logic
39
+ - Creating specialized components for single template analysis workflow
40
+ - Extending the reporter to handle single template output formats
41
+ - Maintaining backward compatibility with existing comparison functionality
42
+
43
+ ## Components and Interfaces
44
+
45
+ ### SingleTemplateAnalyzer
46
+
47
+ A new service class responsible for orchestrating single template cost analysis:
48
+
49
+ ```typescript
50
+ interface SingleTemplateAnalyzer {
51
+ analyzeCosts(template: string, region: string, config?: AnalysisConfig): Promise<SingleTemplateCostResult>;
52
+ }
53
+
54
+ interface AnalysisConfig {
55
+ usageAssumptions?: UsageAssumptionsConfig;
56
+ excludedResourceTypes?: string[];
57
+ cacheConfig?: CacheConfig;
58
+ }
59
+
60
+ interface SingleTemplateCostResult {
61
+ totalMonthlyCost: number;
62
+ currency: string;
63
+ resourceCosts: ResourceCost[];
64
+ costBreakdown: CostBreakdown;
65
+ summary: string;
66
+ }
67
+
68
+ interface CostBreakdown {
69
+ byResourceType: ResourceTypeCost[];
70
+ byConfidenceLevel: ConfidenceLevelCost[];
71
+ assumptions: string[];
72
+ }
73
+
74
+ interface ResourceTypeCost {
75
+ resourceType: string;
76
+ count: number;
77
+ totalCost: number;
78
+ resources: ResourceCost[];
79
+ }
80
+
81
+ interface ConfidenceLevelCost {
82
+ confidence: 'high' | 'medium' | 'low' | 'unknown';
83
+ count: number;
84
+ totalCost: number;
85
+ }
86
+ ```
87
+
88
+ ### Extended API Interface
89
+
90
+ The existing API will be extended with a new function:
91
+
92
+ ```typescript
93
+ interface AnalyzeSingleTemplateOptions {
94
+ template: string;
95
+ region?: string;
96
+ format?: 'text' | 'json' | 'markdown';
97
+ config?: AnalysisConfig;
98
+ }
99
+
100
+ export async function analyzeSingleTemplate(
101
+ options: AnalyzeSingleTemplateOptions
102
+ ): Promise<SingleTemplateCostResult>;
103
+ ```
104
+
105
+ ### CLI Command Extension
106
+
107
+ A new `analyze` command will be added to the CLI:
108
+
109
+ ```bash
110
+ cdk-cost-analyzer analyze <template> [options]
111
+ ```
112
+
113
+ Options:
114
+ - `--region <region>`: AWS region for pricing (default: eu-central-1)
115
+ - `--format <format>`: Output format: text|json|markdown (default: text)
116
+ - `--config <path>`: Path to configuration file
117
+ - `--debug`: Enable verbose debug logging
118
+
119
+ ### SingleTemplateReporter
120
+
121
+ A specialized reporter for single template analysis results:
122
+
123
+ ```typescript
124
+ interface SingleTemplateReporter {
125
+ generateReport(
126
+ result: SingleTemplateCostResult,
127
+ format: ReportFormat,
128
+ options?: SingleTemplateReportOptions
129
+ ): string;
130
+ }
131
+
132
+ interface SingleTemplateReportOptions {
133
+ showBreakdown?: boolean;
134
+ showAssumptions?: boolean;
135
+ groupByType?: boolean;
136
+ sortBy?: 'cost' | 'name' | 'type';
137
+ }
138
+ ```
139
+
140
+ ## Data Models
141
+
142
+ ### Resource Cost Model
143
+
144
+ Extends the existing ResourceCost interface to include additional metadata:
145
+
146
+ ```typescript
147
+ interface EnhancedResourceCost extends ResourceCost {
148
+ properties?: Record<string, any>;
149
+ region: string;
150
+ calculatedAt: Date;
151
+ }
152
+ ```
153
+
154
+ ### Analysis Result Model
155
+
156
+ ```typescript
157
+ interface SingleTemplateCostResult {
158
+ totalMonthlyCost: number;
159
+ currency: string;
160
+ resourceCosts: EnhancedResourceCost[];
161
+ costBreakdown: CostBreakdown;
162
+ summary: string;
163
+ metadata: AnalysisMetadata;
164
+ }
165
+
166
+ interface AnalysisMetadata {
167
+ templateHash: string;
168
+ region: string;
169
+ analyzedAt: Date;
170
+ resourceCount: number;
171
+ supportedResourceCount: number;
172
+ unsupportedResourceCount: number;
173
+ }
174
+ ```
175
+
176
+ ## Correctness Properties
177
+
178
+ *A property is a characteristic or behavior that should hold true across all valid executions of a system-essentially, a formal statement about what the system should do. Properties serve as the bridge between human-readable specifications and machine-verifiable correctness guarantees.*
179
+
180
+ Now I need to use the prework tool to analyze the acceptance criteria before writing the correctness properties:
181
+
182
+ <function_calls>
183
+ <invoke name="prework">
184
+ <parameter name="featureName">single-template-analysis
185
+
186
+ ### Property 1: Template Processing Completeness
187
+ *For any* valid CloudFormation template, analyzing it should calculate costs for all supported resources and return a complete cost breakdown with total monthly cost.
188
+ **Validates: Requirements 1.1, 1.2**
189
+
190
+ ### Property 2: Output Format Consistency
191
+ *For any* single template analysis result, the output should include individual resource costs with logical IDs, resource types, confidence levels, and assumptions, properly grouped by type and sorted by cost in descending order.
192
+ **Validates: Requirements 1.3, 3.1, 3.2, 3.3, 3.4, 3.5, 7.1, 7.2**
193
+
194
+ ### Property 3: Unsupported Resource Handling
195
+ *For any* template containing unsupported resource types, those resources should appear in the output with zero cost and unknown confidence level.
196
+ **Validates: Requirements 1.4, 7.3**
197
+
198
+ ### Property 4: Error Handling Consistency
199
+ *For any* invalid input (malformed templates, missing files, invalid configuration), the system should return descriptive error messages and appropriate exit codes without crashing.
200
+ **Validates: Requirements 1.5, 2.5, 4.4, 6.4**
201
+
202
+ ### Property 5: CLI Command Behavior
203
+ *For any* valid template file and CLI options, the analyze command should execute single template analysis and produce output in the requested format.
204
+ **Validates: Requirements 2.1, 2.3, 6.5**
205
+
206
+ ### Property 6: Regional Pricing Accuracy
207
+ *For any* region parameter provided, the pricing calculations should use region-specific pricing data and note regional variations in assumptions.
208
+ **Validates: Requirements 2.2, 5.4, 7.4**
209
+
210
+ ### Property 7: Debug Logging Activation
211
+ *For any* analysis run with debug flag enabled, verbose logging should be produced for pricing API calls.
212
+ **Validates: Requirements 2.4**
213
+
214
+ ### Property 8: Configuration Application
215
+ *For any* valid configuration provided (usage assumptions, excluded resource types, cache settings), the analysis should apply these settings and reflect them in the results.
216
+ **Validates: Requirements 4.3, 5.1, 5.2, 5.3**
217
+
218
+ ### Property 9: API Interface Consistency
219
+ *For any* valid template processed through the API, the result should have a consistent structure with total cost, resource breakdown, and metadata.
220
+ **Validates: Requirements 4.2**
221
+
222
+ ### Property 10: Resource Cleanup
223
+ *For any* completed analysis, all connections and resources should be properly cleaned up to prevent hanging connections.
224
+ **Validates: Requirements 4.5**
225
+
226
+ ### Property 11: Configuration Graceful Degradation
227
+ *For any* invalid or missing configuration, the system should use default values and continue analysis without failure.
228
+ **Validates: Requirements 5.5**
229
+
230
+ ### Property 12: CI/CD Environment Support
231
+ *For any* CI/CD environment execution, the single template analysis should work without requiring baseline templates and provide appropriate exit codes.
232
+ **Validates: Requirements 6.1, 6.3**
233
+
234
+ ### Property 13: AWS Credentials Error Messaging
235
+ *For any* execution with missing AWS credentials, helpful error messages with setup instructions should be displayed.
236
+ **Validates: Requirements 6.2**
237
+
238
+ ### Property 14: Usage Assumption Transparency
239
+ *For any* cost calculation that uses usage assumptions, those assumptions should be clearly explained in the output.
240
+ **Validates: Requirements 7.5**
241
+
242
+ ### Property 15: Template Parser Robustness
243
+ *For any* CloudFormation template (JSON/YAML, with functions, parameters, or nested stacks), the parser should handle it appropriately or provide specific error messages.
244
+ **Validates: Requirements 8.1, 8.2, 8.3, 8.4, 8.5**
245
+
246
+ ### Property 16: GitHub Integration Completeness
247
+ *For any* implementation task created, corresponding GitHub issues should be generated with complete information, appropriate labels, and dependency references.
248
+ **Validates: Requirements 9.1, 9.2, 9.3, 9.4, 9.5**
249
+
250
+ ### Property 17: Test Result Consistency
251
+ *For any* demo template analyzed multiple times with the same configuration, the results should be consistent.
252
+ **Validates: Requirements 10.4**
253
+
254
+ ### Property 18: Authentication Method Preference
255
+ *For any* AWS operation requiring credentials, OIDC should be used over stored access keys when available.
256
+ **Validates: Requirements 10.5**
257
+
258
+ ## Error Handling
259
+
260
+ The single template analysis feature implements comprehensive error handling across multiple layers:
261
+
262
+ ### Template Processing Errors
263
+ - **Invalid JSON/YAML**: Descriptive parsing errors with line numbers when possible
264
+ - **Missing Templates**: Clear file not found errors with suggested paths
265
+ - **Malformed CloudFormation**: Specific validation errors for CloudFormation structure issues
266
+ - **Unsupported Resources**: Graceful handling with zero cost and clear indication
267
+
268
+ ### Pricing Service Errors
269
+ - **API Failures**: Retry logic with exponential backoff for transient failures
270
+ - **Missing Pricing Data**: Fallback to zero cost with unknown confidence
271
+ - **Rate Limiting**: Automatic retry with appropriate delays
272
+ - **Network Issues**: Timeout handling and connection cleanup
273
+
274
+ ### Configuration Errors
275
+ - **Invalid Config Files**: Validation with specific error messages
276
+ - **Missing AWS Credentials**: Helpful setup instructions for different environments
277
+ - **Invalid Regions**: Clear error messages with supported region list
278
+ - **Permission Issues**: Specific IAM permission guidance
279
+
280
+ ### CLI Error Handling
281
+ - **Exit Codes**: 0 for success, 1 for user errors, 2 for system errors
282
+ - **Error Messages**: Consistent formatting with actionable guidance
283
+ - **Debug Mode**: Enhanced error information when debug flag is enabled
284
+
285
+ ## Testing Strategy
286
+
287
+ The testing strategy employs a dual approach combining unit tests for specific scenarios and property-based tests for comprehensive coverage:
288
+
289
+ ### Unit Testing Approach
290
+ Unit tests focus on specific examples, edge cases, and integration points:
291
+ - **Template Parsing**: Test specific CloudFormation templates with known structures
292
+ - **Error Conditions**: Test specific error scenarios (missing files, invalid JSON, etc.)
293
+ - **CLI Integration**: Test command-line argument parsing and output formatting
294
+ - **Configuration Loading**: Test specific configuration file formats and validation
295
+ - **GitHub Integration**: Test issue creation and status updates with mock GitHub API
296
+
297
+ ### Property-Based Testing Approach
298
+ Property-based tests verify universal properties across randomized inputs:
299
+ - **Template Processing**: Generate random valid CloudFormation templates and verify cost calculation completeness
300
+ - **Output Formatting**: Test output consistency across different template structures and formats
301
+ - **Configuration Handling**: Generate random configuration combinations and verify proper application
302
+ - **Error Handling**: Generate invalid inputs and verify consistent error responses
303
+ - **Regional Pricing**: Test pricing consistency across different regions and resource types
304
+
305
+ ### Testing Configuration
306
+ - **Property Test Iterations**: Minimum 100 iterations per property test
307
+ - **Test Framework**: Jest for unit tests, fast-check for property-based testing
308
+ - **Test Tagging**: Each property test tagged with format: **Feature: single-template-analysis, Property {number}: {property_text}**
309
+ - **Coverage Requirements**: Minimum 90% code coverage for new components
310
+ - **Integration Testing**: End-to-end tests using demo templates from testaccount01
311
+
312
+ ### Verification Testing
313
+ - **Demo Templates**: Use templates from demo/cdk.out.1 and demo/cdk.out.2 directories
314
+ - **AWS Profile**: All tests use testaccount01 profile for authentication
315
+ - **OIDC Authentication**: GitHub Actions authenticate using OIDC to testaccount01
316
+ - **Consistency Verification**: Same template should produce identical results across runs
317
+ - **Performance Testing**: Verify analysis completes within reasonable time limits
318
+
319
+ The testing strategy ensures both correctness through property-based testing and practical reliability through comprehensive unit testing of specific scenarios and edge cases.
@@ -0,0 +1,138 @@
1
+ # Requirements Document
2
+
3
+ ## Introduction
4
+
5
+ This document specifies the requirements for adding single template cost analysis functionality to the cdk-cost-analyzer tool. The feature will enable users to analyze the estimated monthly costs of all resources in a single CloudFormation template without requiring a comparison baseline.
6
+
7
+ ## Glossary
8
+
9
+ - **Single_Template_Analysis**: The process of analyzing a single CloudFormation template to estimate monthly costs of all resources
10
+ - **Cost_Analyzer**: The cdk-cost-analyzer tool that currently supports template comparison
11
+ - **Template_Parser**: The existing component that parses CloudFormation templates
12
+ - **Pricing_Service**: The existing service that calculates resource costs using AWS Pricing API
13
+ - **CLI**: Command Line Interface for the cost analyzer tool
14
+ - **API**: Application Programming Interface for programmatic access
15
+ - **Resource_Cost**: The estimated monthly cost for a specific AWS resource
16
+ - **Cost_Breakdown**: A detailed view of costs organized by resource type or logical ID
17
+
18
+ ## Requirements
19
+
20
+ ### Requirement 1
21
+
22
+ **User Story:** As a developer, I want to analyze a single CloudFormation template to see estimated monthly costs, so that I can understand the cost implications before deployment.
23
+
24
+ #### Acceptance Criteria
25
+
26
+ 1. WHEN a user provides a single CloudFormation template file, THE Cost_Analyzer SHALL parse the template and calculate estimated monthly costs for all resources
27
+ 2. WHEN the analysis is complete, THE Cost_Analyzer SHALL display the total estimated monthly cost
28
+ 3. WHEN displaying results, THE Cost_Analyzer SHALL show individual resource costs with logical IDs and resource types
29
+ 4. WHEN a resource type is not supported for cost calculation, THE Cost_Analyzer SHALL indicate this in the output with zero cost
30
+ 5. WHEN the template contains invalid JSON or YAML, THE Cost_Analyzer SHALL return a descriptive error message
31
+
32
+ ### Requirement 2
33
+
34
+ **User Story:** As a DevOps engineer, I want to get cost estimates through a CLI command, so that I can integrate cost analysis into my deployment workflows.
35
+
36
+ #### Acceptance Criteria
37
+
38
+ 1. WHEN a user runs the analyze command with a template path, THE CLI SHALL execute single template analysis
39
+ 2. WHEN the --region option is provided, THE Cost_Analyzer SHALL use that region for pricing calculations
40
+ 3. WHEN the --format option is provided, THE Cost_Analyzer SHALL output results in the specified format (text, json, markdown)
41
+ 4. WHEN the --debug option is provided, THE Cost_Analyzer SHALL enable verbose logging for pricing API calls
42
+ 5. WHEN the template file does not exist, THE CLI SHALL display an error message and exit with code 1
43
+
44
+ ### Requirement 3
45
+
46
+ **User Story:** As a cost analyst, I want to understand the cost breakdown of existing templates, so that I can identify the most expensive resources and optimize costs.
47
+
48
+ #### Acceptance Criteria
49
+
50
+ 1. WHEN analyzing a template, THE Cost_Analyzer SHALL group resources by type in the cost breakdown
51
+ 2. WHEN displaying cost breakdown, THE Cost_Analyzer SHALL sort resources by cost in descending order
52
+ 3. WHEN a resource has cost calculation assumptions, THE Cost_Analyzer SHALL display these assumptions
53
+ 4. WHEN multiple resources of the same type exist, THE Cost_Analyzer SHALL show both individual and aggregate costs per type
54
+ 5. WHEN the confidence level for cost calculation is low or unknown, THE Cost_Analyzer SHALL indicate this in the output
55
+
56
+ ### Requirement 4
57
+
58
+ **User Story:** As an application developer, I want to access single template analysis programmatically, so that I can integrate cost analysis into my applications and tools.
59
+
60
+ #### Acceptance Criteria
61
+
62
+ 1. WHEN calling the API with a single template, THE API SHALL accept a new analyzeSingleTemplate function
63
+ 2. WHEN the API processes a single template, THE API SHALL return a structured result with total cost and resource breakdown
64
+ 3. WHEN configuration options are provided, THE API SHALL apply usage assumptions and excluded resource types
65
+ 4. WHEN the API encounters errors, THE API SHALL throw typed exceptions with descriptive messages
66
+ 5. WHEN the analysis is complete, THE API SHALL clean up resources to prevent hanging connections
67
+
68
+ ### Requirement 5
69
+
70
+ **User Story:** As a system administrator, I want to configure cost analysis behavior, so that I can customize the analysis for my organization's needs.
71
+
72
+ #### Acceptance Criteria
73
+
74
+ 1. WHEN a configuration file is provided, THE Cost_Analyzer SHALL apply usage assumptions for single template analysis
75
+ 2. WHEN excluded resource types are configured, THE Cost_Analyzer SHALL skip cost calculation for those types
76
+ 3. WHEN cache configuration is provided, THE Cost_Analyzer SHALL use cached pricing data when available
77
+ 4. WHEN region-specific pricing is needed, THE Cost_Analyzer SHALL use the appropriate regional pricing data
78
+ 5. WHEN configuration is invalid or missing, THE Cost_Analyzer SHALL use default values and continue analysis
79
+
80
+ ### Requirement 6
81
+
82
+ **User Story:** As a developer using CI/CD pipelines, I want to analyze template costs in automated workflows, so that I can catch cost issues early in the development process.
83
+
84
+ #### Acceptance Criteria
85
+
86
+ 1. WHEN running in CI/CD environments, THE Cost_Analyzer SHALL support single template analysis without requiring baseline templates
87
+ 2. WHEN AWS credentials are not configured, THE Cost_Analyzer SHALL display helpful error messages with setup instructions
88
+ 3. WHEN the analysis completes successfully, THE Cost_Analyzer SHALL exit with code 0
89
+ 4. WHEN errors occur during analysis, THE Cost_Analyzer SHALL exit with appropriate error codes
90
+ 5. WHEN output format is JSON, THE Cost_Analyzer SHALL provide machine-readable results for further processing
91
+
92
+ ### Requirement 7
93
+
94
+ **User Story:** As a cost-conscious developer, I want to see cost estimates with confidence indicators, so that I can understand the reliability of the estimates.
95
+
96
+ #### Acceptance Criteria
97
+
98
+ 1. WHEN displaying resource costs, THE Cost_Analyzer SHALL include confidence levels (high, medium, low, unknown)
99
+ 2. WHEN cost calculations use assumptions, THE Cost_Analyzer SHALL list all assumptions made
100
+ 3. WHEN pricing data is unavailable for a resource, THE Cost_Analyzer SHALL indicate this with unknown confidence
101
+ 4. WHEN regional pricing varies significantly, THE Cost_Analyzer SHALL note this in the assumptions
102
+ 5. WHEN usage patterns affect costs significantly, THE Cost_Analyzer SHALL explain the usage assumptions used
103
+
104
+ ### Requirement 8
105
+
106
+ **User Story:** As a template author, I want to validate that my CloudFormation templates can be analyzed for costs, so that I can ensure cost transparency for users of my templates.
107
+
108
+ #### Acceptance Criteria
109
+
110
+ 1. WHEN parsing CloudFormation templates, THE Template_Parser SHALL support both JSON and YAML formats
111
+ 2. WHEN templates use CloudFormation functions, THE Template_Parser SHALL handle intrinsic functions appropriately
112
+ 3. WHEN templates reference parameters, THE Template_Parser SHALL use default values or indicate missing parameters
113
+ 4. WHEN templates are malformed, THE Template_Parser SHALL provide specific error messages about the parsing failure
114
+ 5. WHEN templates contain nested stacks, THE Template_Parser SHALL analyze the parent template resources only
115
+
116
+ ### Requirement 9
117
+
118
+ **User Story:** As a project manager, I want to track implementation progress through GitHub issues, so that I can monitor development status and coordinate team efforts.
119
+
120
+ #### Acceptance Criteria
121
+
122
+ 1. WHEN implementation tasks are created, THE System SHALL generate corresponding GitHub issues for each task
123
+ 2. WHEN a task is completed, THE System SHALL update the corresponding GitHub issue status
124
+ 3. WHEN issues are created, THE System SHALL include task descriptions and acceptance criteria
125
+ 4. WHEN tasks have dependencies, THE System SHALL reference related issues in the GitHub issue description
126
+ 5. WHEN implementation begins, THE System SHALL assign appropriate labels to categorize the issues (enhancement, bug, documentation)
127
+
128
+ ### Requirement 10
129
+
130
+ **User Story:** As a quality assurance engineer, I want to verify the single template analysis functionality using standardized test data, so that I can ensure the feature works correctly across different scenarios.
131
+
132
+ #### Acceptance Criteria
133
+
134
+ 1. WHEN testing the single template analysis feature, THE System SHALL use the testaccount01 AWS profile for authentication
135
+ 2. WHEN running verification tests, THE System SHALL analyze templates from the demo/cdk.out.1 and demo/cdk.out.2 directories
136
+ 3. WHEN GitHub Actions runs tests, THE System SHALL authenticate to testaccount01 using OIDC (OpenID Connect)
137
+ 4. WHEN tests execute, THE System SHALL verify that single template analysis produces consistent results for the demo templates
138
+ 5. WHEN AWS credentials are required, THE System SHALL use the configured OIDC connection rather than stored access keys
@@ -0,0 +1,243 @@
1
+ # Implementation Plan: Single Template Cost Analysis
2
+
3
+ ## Overview
4
+
5
+ This implementation plan converts the single template cost analysis design into discrete coding tasks. Each task builds incrementally on previous work, with property-based tests integrated throughout to catch errors early. The plan includes GitHub issue creation for project tracking and uses the existing TypeScript codebase architecture.
6
+
7
+ ## Tasks
8
+
9
+ - [ ] 1. Create GitHub issues for project tracking
10
+ - Create GitHub issues for each implementation task with appropriate labels
11
+ - Include task descriptions, acceptance criteria, and dependency references
12
+ - Assign "enhancement" labels for new features and "testing" labels for test tasks
13
+ - _Requirements: 9.1, 9.2, 9.3, 9.4, 9.5_
14
+
15
+ - [ ] 2. Set up core interfaces and types for single template analysis
16
+ - [ ] 2.1 Create SingleTemplateAnalyzer interface and types
17
+ - Define AnalysisConfig, SingleTemplateCostResult, CostBreakdown interfaces
18
+ - Create ResourceTypeCost and ConfidenceLevelCost interfaces
19
+ - Add AnalysisMetadata interface for tracking analysis information
20
+ - _Requirements: 4.1, 4.2_
21
+
22
+ - [ ] 2.2 Write property test for interface completeness
23
+ - **Property 9: API Interface Consistency**
24
+ - **Validates: Requirements 4.2**
25
+
26
+ - [ ] 3. Implement SingleTemplateAnalyzer service
27
+ - [ ] 3.1 Create SingleTemplateAnalyzer class with core analysis logic
28
+ - Implement analyzeCosts method that processes single templates
29
+ - Integrate with existing TemplateParser and PricingService
30
+ - Handle resource cost calculation and aggregation
31
+ - _Requirements: 1.1, 1.2, 4.2_
32
+
33
+ - [ ] 3.2 Write property test for template processing completeness
34
+ - **Property 1: Template Processing Completeness**
35
+ - **Validates: Requirements 1.1, 1.2**
36
+
37
+ - [ ] 3.3 Implement cost breakdown generation
38
+ - Group resources by type and confidence level
39
+ - Calculate aggregate costs and resource counts
40
+ - Generate assumptions list from individual resource calculations
41
+ - _Requirements: 3.1, 3.4, 7.2_
42
+
43
+ - [ ] 3.4 Write property test for cost breakdown accuracy
44
+ - **Property 2: Output Format Consistency**
45
+ - **Validates: Requirements 3.1, 3.4, 7.2**
46
+
47
+ - [ ] 4. Extend API with analyzeSingleTemplate function
48
+ - [ ] 4.1 Add analyzeSingleTemplate function to API module
49
+ - Create AnalyzeSingleTemplateOptions interface
50
+ - Implement function that uses SingleTemplateAnalyzer
51
+ - Handle configuration application and error handling
52
+ - _Requirements: 4.1, 4.3, 4.4_
53
+
54
+ - [ ] 4.2 Write property test for configuration handling
55
+ - **Property 8: Configuration Application**
56
+ - **Validates: Requirements 4.3, 5.1, 5.2**
57
+
58
+ - [ ] 4.3 Implement resource cleanup in API function
59
+ - Ensure PricingService.destroy() is called after analysis
60
+ - Handle cleanup in error scenarios using try/finally
61
+ - _Requirements: 4.5_
62
+
63
+ - [ ] 4.4 Write property test for resource cleanup
64
+ - **Property 10: Resource Cleanup**
65
+ - **Validates: Requirements 4.5**
66
+
67
+ - [ ] 5. Create SingleTemplateReporter for specialized output formatting
68
+ - [ ] 5.1 Implement SingleTemplateReporter class
69
+ - Create generateReport method for single template results
70
+ - Support text, JSON, and markdown output formats
71
+ - Implement resource sorting by cost (descending order)
72
+ - _Requirements: 1.3, 2.3, 3.2_
73
+
74
+ - [ ] 5.2 Implement cost breakdown formatting
75
+ - Format resources grouped by type with individual and aggregate costs
76
+ - Display confidence levels and assumptions clearly
77
+ - Handle unsupported resources with zero cost indication
78
+ - _Requirements: 1.4, 3.3, 3.5, 7.1, 7.3_
79
+
80
+ - [ ] 5.3 Write property test for output format consistency
81
+ - **Property 2: Output Format Consistency**
82
+ - **Validates: Requirements 1.3, 3.2, 3.3, 7.1**
83
+
84
+ - [ ] 5.4 Write property test for unsupported resource handling
85
+ - **Property 3: Unsupported Resource Handling**
86
+ - **Validates: Requirements 1.4, 7.3**
87
+
88
+ - [ ] 6. Checkpoint - Core functionality complete
89
+ - Ensure all tests pass, ask the user if questions arise.
90
+
91
+ - [ ] 7. Add CLI analyze command
92
+ - [ ] 7.1 Implement analyze command in CLI module
93
+ - Add command definition with template argument and options
94
+ - Handle --region, --format, --config, --debug options
95
+ - Integrate with analyzeSingleTemplate API function
96
+ - _Requirements: 2.1, 2.2, 2.3, 2.4_
97
+
98
+ - [ ] 7.2 Implement file handling and error reporting
99
+ - Check template file existence with descriptive errors
100
+ - Handle invalid templates with specific error messages
101
+ - Implement proper exit codes (0 for success, 1 for errors)
102
+ - _Requirements: 2.5, 6.3, 6.4_
103
+
104
+ - [ ] 7.3 Write property test for CLI command behavior
105
+ - **Property 5: CLI Command Behavior**
106
+ - **Validates: Requirements 2.1, 2.3**
107
+
108
+ - [ ] 7.4 Write property test for error handling consistency
109
+ - **Property 4: Error Handling Consistency**
110
+ - **Validates: Requirements 1.5, 2.5, 4.4, 6.4**
111
+
112
+ - [ ] 8. Implement enhanced error handling and messaging
113
+ - [ ] 8.1 Add AWS credentials error handling
114
+ - Detect missing AWS credentials in CLI and API
115
+ - Provide helpful setup instructions for different environments
116
+ - Include specific guidance for CI/CD environments
117
+ - _Requirements: 6.2_
118
+
119
+ - [ ] 8.2 Implement template parser error improvements
120
+ - Handle JSON/YAML parsing errors with line numbers
121
+ - Support CloudFormation functions and parameters gracefully
122
+ - Provide specific error messages for malformed templates
123
+ - _Requirements: 8.1, 8.2, 8.3, 8.4, 8.5_
124
+
125
+ - [ ] 8.3 Write property test for template parser robustness
126
+ - **Property 15: Template Parser Robustness**
127
+ - **Validates: Requirements 8.1, 8.2, 8.3, 8.4, 8.5**
128
+
129
+ - [ ] 8.4 Write property test for AWS credentials error messaging
130
+ - **Property 13: AWS Credentials Error Messaging**
131
+ - **Validates: Requirements 6.2**
132
+
133
+ - [ ] 9. Add regional pricing and configuration features
134
+ - [ ] 9.1 Implement regional pricing accuracy
135
+ - Ensure region parameter is properly passed to pricing service
136
+ - Add regional pricing variation notes to assumptions
137
+ - Handle unsupported regions with clear error messages
138
+ - _Requirements: 5.4, 7.4_
139
+
140
+ - [ ] 9.2 Implement configuration graceful degradation
141
+ - Handle invalid configuration files without failing analysis
142
+ - Use default values when configuration is missing or invalid
143
+ - Log configuration issues without stopping analysis
144
+ - _Requirements: 5.5_
145
+
146
+ - [ ] 9.3 Write property test for regional pricing accuracy
147
+ - **Property 6: Regional Pricing Accuracy**
148
+ - **Validates: Requirements 2.2, 5.4, 7.4**
149
+
150
+ - [ ] 9.4 Write property test for configuration graceful degradation
151
+ - **Property 11: Configuration Graceful Degradation**
152
+ - **Validates: Requirements 5.5**
153
+
154
+ - [ ] 10. Implement debug logging and transparency features
155
+ - [ ] 10.1 Add debug logging activation
156
+ - Enable verbose logging when --debug flag is used
157
+ - Log pricing API calls and responses
158
+ - Include timing information for performance analysis
159
+ - _Requirements: 2.4_
160
+
161
+ - [ ] 10.2 Implement usage assumption transparency
162
+ - Clearly document all usage assumptions in output
163
+ - Explain how assumptions affect cost calculations
164
+ - Note when custom assumptions from configuration are used
165
+ - _Requirements: 7.5_
166
+
167
+ - [ ] 10.3 Write property test for debug logging activation
168
+ - **Property 7: Debug Logging Activation**
169
+ - **Validates: Requirements 2.4**
170
+
171
+ - [ ] 10.4 Write property test for usage assumption transparency
172
+ - **Property 14: Usage Assumption Transparency**
173
+ - **Validates: Requirements 7.5**
174
+
175
+ - [ ] 11. Add CI/CD and authentication support
176
+ - [ ] 11.1 Implement CI/CD environment support
177
+ - Ensure single template analysis works in automated environments
178
+ - Support analysis without requiring baseline templates
179
+ - Handle environment variable detection for CI/CD
180
+ - _Requirements: 6.1_
181
+
182
+ - [ ] 11.2 Implement OIDC authentication preference
183
+ - Prefer OIDC authentication over stored access keys
184
+ - Handle GitHub Actions OIDC authentication
185
+ - Provide clear guidance for OIDC setup
186
+ - _Requirements: 10.5_
187
+
188
+ - [ ] 11.3 Write property test for CI/CD environment support
189
+ - **Property 12: CI/CD Environment Support**
190
+ - **Validates: Requirements 6.1, 6.3**
191
+
192
+ - [ ] 11.4 Write property test for authentication method preference
193
+ - **Property 18: Authentication Method Preference**
194
+ - **Validates: Requirements 10.5**
195
+
196
+ - [ ] 12. Create verification tests with demo templates
197
+ - [ ] 12.1 Set up test infrastructure for demo templates
198
+ - Configure tests to use testaccount01 AWS profile
199
+ - Set up test data using demo/cdk.out.1 and demo/cdk.out.2 templates
200
+ - Configure GitHub Actions with OIDC authentication
201
+ - _Requirements: 10.1, 10.2, 10.3_
202
+
203
+ - [ ] 12.2 Write property test for result consistency
204
+ - **Property 17: Test Result Consistency**
205
+ - **Validates: Requirements 10.4**
206
+
207
+ - [ ] 12.3 Create integration tests with real AWS pricing
208
+ - Test single template analysis with actual demo templates
209
+ - Verify cost calculations are reasonable and consistent
210
+ - Test different output formats with demo data
211
+ - _Requirements: 10.4_
212
+
213
+ - [ ] 13. Final integration and documentation
214
+ - [ ] 13.1 Update API exports and documentation
215
+ - Export new analyzeSingleTemplate function from main API
216
+ - Update TypeScript type definitions
217
+ - Add JSDoc comments for new interfaces and functions
218
+ - _Requirements: 4.1_
219
+
220
+ - [ ] 13.2 Update CLI help and usage documentation
221
+ - Add analyze command to CLI help text
222
+ - Update README with single template analysis examples
223
+ - Document new command-line options and usage patterns
224
+ - _Requirements: 2.1_
225
+
226
+ - [ ] 13.3 Update GitHub issue status
227
+ - Mark completed tasks as done in corresponding GitHub issues
228
+ - Update issue labels and close completed issues
229
+ - Document any remaining work or follow-up tasks
230
+ - _Requirements: 9.2_
231
+
232
+ - [ ] 14. Final checkpoint - Ensure all tests pass
233
+ - Ensure all tests pass, ask the user if questions arise.
234
+
235
+ ## Notes
236
+
237
+ - Each task references specific requirements for traceability
238
+ - Property tests validate universal correctness properties from the design
239
+ - Unit tests validate specific examples and edge cases
240
+ - GitHub issues will be created for each task to enable project tracking
241
+ - Tests use testaccount01 profile and demo templates for verification
242
+ - OIDC authentication is preferred over stored AWS credentials
243
+ - All tasks are required for comprehensive implementation from start
@@ -1 +1 @@
1
- v0.1.8
1
+ v0.1.10
package/package.json CHANGED
@@ -56,7 +56,7 @@
56
56
  "jest": "^30.2.0",
57
57
  "jest-junit": "^16",
58
58
  "lint-staged": "^15.0.0",
59
- "projen": "^0.99.3",
59
+ "projen": "^0.99.4",
60
60
  "ts-jest": "^29.4.6",
61
61
  "ts-node": "^10.9.2",
62
62
  "typescript": "^5.9.3"
@@ -82,7 +82,7 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "version": "0.1.8",
85
+ "version": "0.1.10",
86
86
  "bugs": {
87
87
  "url": "https://github.com/buildinginthecloud/cdk-cost-analyzer/issues"
88
88
  },