cdk-cost-analyzer 0.1.1
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.
- package/.cdk-cost-analyzer-cache/metadata.json +12 -0
- package/.gitlab-ci.yml +214 -0
- package/.husky/pre-commit +12 -0
- package/.kiro/hooks/accessibility-audit.kiro.hook +18 -0
- package/.kiro/hooks/api-schema-validation.kiro.hook +21 -0
- package/.kiro/hooks/auto-test-on-save.kiro.hook +19 -0
- package/.kiro/hooks/cdk-synth-on-change.kiro.hook +20 -0
- package/.kiro/hooks/code-coverage-check.kiro.hook +14 -0
- package/.kiro/hooks/commit-message-helper.kiro.hook +14 -0
- package/.kiro/hooks/dependency-update-check.kiro.hook +14 -0
- package/.kiro/hooks/env-file-validation.kiro.hook +18 -0
- package/.kiro/hooks/lint-and-format-on-save.kiro.hook +21 -0
- package/.kiro/hooks/mcp-config-validation.kiro.hook +17 -0
- package/.kiro/hooks/mcp-server-test.kiro.hook +14 -0
- package/.kiro/hooks/performance-analysis.kiro.hook +14 -0
- package/.kiro/hooks/readme-spell-check.kiro.hook +14 -0
- package/.kiro/hooks/security-scan-on-dependency-change.kiro.hook +21 -0
- package/.kiro/hooks/translation-update.kiro.hook +18 -0
- package/.kiro/hooks/update-documentation.kiro.hook +18 -0
- package/.kiro/settings/mcp.json +20 -0
- package/.kiro/specs/cdk-cost-analyzer/design.md +620 -0
- package/.kiro/specs/cdk-cost-analyzer/requirements.md +183 -0
- package/.kiro/specs/cdk-cost-analyzer/tasks.md +357 -0
- package/.kiro/specs/github-actions-ci/design.md +281 -0
- package/.kiro/specs/github-actions-ci/requirements.md +86 -0
- package/.kiro/specs/github-actions-ci/tasks.md +115 -0
- package/.kiro/specs/nlb-calculator-test-coverage/design.md +190 -0
- package/.kiro/specs/nlb-calculator-test-coverage/requirements.md +84 -0
- package/.kiro/specs/nlb-calculator-test-coverage/tasks.md +150 -0
- package/.kiro/specs/production-readiness/design.md +1213 -0
- package/.kiro/specs/production-readiness/requirements.md +312 -0
- package/.kiro/specs/production-readiness/tasks.md +269 -0
- package/.kiro/specs/repository-cleanup/design.md +283 -0
- package/.kiro/specs/repository-cleanup/requirements.md +74 -0
- package/.kiro/specs/repository-cleanup/tasks.md +64 -0
- package/.kiro/steering/aws-cli-best-practices.md +41 -0
- package/.kiro/steering/cdk-best-practices.md +49 -0
- package/.kiro/steering/development-standards.md +54 -0
- package/.kiro/steering/docker-best-practices.md +34 -0
- package/.kiro/steering/documentation-style.md +151 -0
- package/.kiro/steering/git-best-practices.md +37 -0
- package/.kiro/steering/mcp-best-practices.md +95 -0
- package/.kiro/steering/python-best-practices.md +48 -0
- package/.kiro/steering/react-best-practices.md +44 -0
- package/.kiro/steering/security-best-practices.md +41 -0
- package/.kiro/steering/testing-best-practices.md +59 -0
- package/.kiro/steering/typescript-best-practices.md +40 -0
- package/CHANGELOG.md +49 -0
- package/CONTRIBUTING.md +258 -0
- package/LICENSE +19 -0
- package/README.md +480 -0
- package/SECURITY.md +117 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.js +65 -0
- package/dist/api/types.d.ts +15 -0
- package/dist/api/types.js +3 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +262 -0
- package/dist/config/ConfigManager.d.ts +40 -0
- package/dist/config/ConfigManager.js +238 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +19 -0
- package/dist/config/types.d.ts +72 -0
- package/dist/config/types.js +15 -0
- package/dist/diff/DiffEngine.d.ts +7 -0
- package/dist/diff/DiffEngine.js +73 -0
- package/dist/diff/index.d.ts +2 -0
- package/dist/diff/index.js +21 -0
- package/dist/diff/types.d.ts +20 -0
- package/dist/diff/types.js +3 -0
- package/dist/integrations/GitLabIntegration.d.ts +7 -0
- package/dist/integrations/GitLabIntegration.js +45 -0
- package/dist/integrations/index.d.ts +2 -0
- package/dist/integrations/index.js +21 -0
- package/dist/integrations/types.d.ts +11 -0
- package/dist/integrations/types.js +13 -0
- package/dist/parser/TemplateParser.d.ts +8 -0
- package/dist/parser/TemplateParser.js +75 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.js +22 -0
- package/dist/parser/types.d.ts +30 -0
- package/dist/parser/types.js +3 -0
- package/dist/pipeline/PipelineOrchestrator.d.ts +23 -0
- package/dist/pipeline/PipelineOrchestrator.js +191 -0
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +19 -0
- package/dist/pipeline/types.d.ts +41 -0
- package/dist/pipeline/types.js +13 -0
- package/dist/pricing/CacheManager.d.ts +75 -0
- package/dist/pricing/CacheManager.js +195 -0
- package/dist/pricing/PricingClient.d.ts +17 -0
- package/dist/pricing/PricingClient.js +122 -0
- package/dist/pricing/PricingService.d.ts +16 -0
- package/dist/pricing/PricingService.js +149 -0
- package/dist/pricing/calculators/ALBCalculator.d.ts +16 -0
- package/dist/pricing/calculators/ALBCalculator.js +163 -0
- package/dist/pricing/calculators/APIGatewayCalculator.d.ts +10 -0
- package/dist/pricing/calculators/APIGatewayCalculator.js +177 -0
- package/dist/pricing/calculators/CloudFrontCalculator.d.ts +59 -0
- package/dist/pricing/calculators/CloudFrontCalculator.js +151 -0
- package/dist/pricing/calculators/DynamoDBCalculator.d.ts +9 -0
- package/dist/pricing/calculators/DynamoDBCalculator.js +146 -0
- package/dist/pricing/calculators/EC2Calculator.d.ts +7 -0
- package/dist/pricing/calculators/EC2Calculator.js +80 -0
- package/dist/pricing/calculators/ECSCalculator.d.ts +9 -0
- package/dist/pricing/calculators/ECSCalculator.js +116 -0
- package/dist/pricing/calculators/ElastiCacheCalculator.d.ts +8 -0
- package/dist/pricing/calculators/ElastiCacheCalculator.js +106 -0
- package/dist/pricing/calculators/LambdaCalculator.d.ts +13 -0
- package/dist/pricing/calculators/LambdaCalculator.js +111 -0
- package/dist/pricing/calculators/NLBCalculator.d.ts +16 -0
- package/dist/pricing/calculators/NLBCalculator.js +138 -0
- package/dist/pricing/calculators/NatGatewayCalculator.d.ts +12 -0
- package/dist/pricing/calculators/NatGatewayCalculator.js +116 -0
- package/dist/pricing/calculators/RDSCalculator.d.ts +9 -0
- package/dist/pricing/calculators/RDSCalculator.js +103 -0
- package/dist/pricing/calculators/S3Calculator.d.ts +8 -0
- package/dist/pricing/calculators/S3Calculator.js +68 -0
- package/dist/pricing/calculators/VPCEndpointCalculator.d.ts +12 -0
- package/dist/pricing/calculators/VPCEndpointCalculator.js +129 -0
- package/dist/pricing/index.d.ts +10 -0
- package/dist/pricing/index.js +37 -0
- package/dist/pricing/types.d.ts +53 -0
- package/dist/pricing/types.js +22 -0
- package/dist/releasetag.txt +1 -0
- package/dist/reporter/Reporter.d.ts +18 -0
- package/dist/reporter/Reporter.js +412 -0
- package/dist/reporter/index.d.ts +2 -0
- package/dist/reporter/index.js +21 -0
- package/dist/reporter/types.d.ts +72 -0
- package/dist/reporter/types.js +3 -0
- package/dist/synthesis/SynthesisOrchestrator.d.ts +26 -0
- package/dist/synthesis/SynthesisOrchestrator.js +243 -0
- package/dist/synthesis/index.d.ts +2 -0
- package/dist/synthesis/index.js +19 -0
- package/dist/synthesis/types.d.ts +17 -0
- package/dist/synthesis/types.js +13 -0
- package/dist/threshold/ThresholdEnforcer.d.ts +29 -0
- package/dist/threshold/ThresholdEnforcer.js +143 -0
- package/dist/threshold/index.d.ts +2 -0
- package/dist/threshold/index.js +19 -0
- package/dist/threshold/types.d.ts +15 -0
- package/dist/threshold/types.js +17 -0
- package/docs/CALCULATORS.md +820 -0
- package/docs/CI_CD.md +608 -0
- package/docs/CONFIGURATION.md +407 -0
- package/docs/DEVELOPMENT.md +387 -0
- package/docs/RELEASE.md +223 -0
- package/docs/TROUBLESHOOTING.md +847 -0
- package/examples/.cdk-cost-analyzer.yml +85 -0
- package/examples/.gitlab-ci.yml +125 -0
- package/examples/api-usage.js +26 -0
- package/examples/complex/base.json +16 -0
- package/examples/complex/target.json +29 -0
- package/examples/monorepo/.gitlab-ci.yml +251 -0
- package/examples/monorepo/README.md +341 -0
- package/examples/monorepo/package.json +27 -0
- package/examples/monorepo/packages/backend-infra/.cdk-cost-analyzer.yml +34 -0
- package/examples/monorepo/packages/backend-infra/bin/app.ts +16 -0
- package/examples/monorepo/packages/backend-infra/cdk.json +7 -0
- package/examples/monorepo/packages/backend-infra/lib/backend-stack.ts +128 -0
- package/examples/monorepo/packages/backend-infra/package.json +30 -0
- package/examples/monorepo/packages/backend-infra/tsconfig.json +11 -0
- package/examples/monorepo/packages/data-infra/.cdk-cost-analyzer.yml +38 -0
- package/examples/monorepo/packages/data-infra/bin/app.ts +16 -0
- package/examples/monorepo/packages/data-infra/cdk.json +7 -0
- package/examples/monorepo/packages/data-infra/lib/data-stack.ts +121 -0
- package/examples/monorepo/packages/data-infra/package.json +30 -0
- package/examples/monorepo/packages/data-infra/tsconfig.json +11 -0
- package/examples/monorepo/packages/frontend-infra/.cdk-cost-analyzer.yml +31 -0
- package/examples/monorepo/packages/frontend-infra/bin/app.ts +16 -0
- package/examples/monorepo/packages/frontend-infra/cdk.json +7 -0
- package/examples/monorepo/packages/frontend-infra/lib/frontend-stack.ts +60 -0
- package/examples/monorepo/packages/frontend-infra/package.json +30 -0
- package/examples/monorepo/packages/frontend-infra/tsconfig.json +11 -0
- package/examples/monorepo/tsconfig.json +35 -0
- package/examples/multi-stack/.cdk-cost-analyzer.yml +72 -0
- package/examples/multi-stack/.gitlab-ci.yml +184 -0
- package/examples/multi-stack/README.md +279 -0
- package/examples/multi-stack/bin/app.ts +36 -0
- package/examples/multi-stack/cdk.json +72 -0
- package/examples/multi-stack/lib/compute-stack.ts +128 -0
- package/examples/multi-stack/lib/networking-stack.ts +69 -0
- package/examples/multi-stack/lib/storage-stack.ts +141 -0
- package/examples/multi-stack/package-lock.json +4437 -0
- package/examples/multi-stack/package.json +42 -0
- package/examples/multi-stack/tsconfig.json +34 -0
- package/examples/simple/base.json +8 -0
- package/examples/simple/target.json +14 -0
- package/examples/single-stack/.NVP +0 -0
- package/examples/single-stack/.cdk-cost-analyzer.yml +52 -0
- package/examples/single-stack/.gitlab-ci.yml +126 -0
- package/examples/single-stack/README.md +184 -0
- package/examples/single-stack/UeK +0 -0
- package/examples/single-stack/bin/app.ts +16 -0
- package/examples/single-stack/cdk.json +72 -0
- package/examples/single-stack/lib/infrastructure-stack.ts +119 -0
- package/examples/single-stack/package-lock.json +4443 -0
- package/examples/single-stack/package.json +38 -0
- package/examples/single-stack/tsconfig.json +34 -0
- package/package.json +139 -0
- package/test-cdk-project/README-COMPUTE.md +141 -0
- package/test-cdk-project/README.md +95 -0
- package/test-cdk-project/app-with-compute.js +102 -0
- package/test-cdk-project/app.js +81 -0
- package/test-cdk-project/cdk-compute.json +3 -0
- package/test-cdk-project/cdk.context.json +7 -0
- package/test-cdk-project/cdk.json +3 -0
- package/test-cdk-project/cdk.out/TestStack.assets.json +21 -0
- package/test-cdk-project/cdk.out/TestStack.template.json +115 -0
- package/test-cdk-project/cdk.out/cdk.out +1 -0
- package/test-cdk-project/cdk.out/manifest.json +503 -0
- package/test-cdk-project/cdk.out/tree.json +1 -0
- package/test-cdk-project/cdk.out.base/TestStack.assets.json +21 -0
- package/test-cdk-project/cdk.out.base/TestStack.template.json +115 -0
- package/test-cdk-project/cdk.out.base/cdk.out +1 -0
- package/test-cdk-project/cdk.out.base/manifest.json +503 -0
- package/test-cdk-project/cdk.out.base/tree.json +1 -0
- package/test-cdk-project/cdk.out.target/TestStack.assets.json +21 -0
- package/test-cdk-project/cdk.out.target/TestStack.template.json +183 -0
- package/test-cdk-project/cdk.out.target/cdk.out +1 -0
- package/test-cdk-project/cdk.out.target/manifest.json +521 -0
- package/test-cdk-project/cdk.out.target/tree.json +1 -0
- package/test-cdk-project/package-lock.json +422 -0
- package/test-cdk-project/package.json +17 -0
- package/tools/workflows/README.md +102 -0
- package/tools/workflows/validate-workflows.js +109 -0
- package/tools/workflows/workflow-utils.ts +181 -0
|
@@ -0,0 +1,1213 @@
|
|
|
1
|
+
# Design Document
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Production Readiness design extends the CDK Cost Analyzer to be fully production-ready for real-world developer workflows. This design addresses three critical areas: automatic CDK synthesis in CI/CD pipelines, cost threshold enforcement with configuration flexibility, and extended resource coverage for commonly used AWS services.
|
|
6
|
+
|
|
7
|
+
The design maintains the existing modular architecture while adding new components for synthesis orchestration, configuration management, threshold enforcement, and additional resource calculators.
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
### Enhanced Architecture
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
┌─────────────────────────────────────────────────────────┐
|
|
15
|
+
│ Entry Points │
|
|
16
|
+
│ CLI | API | GitLab CI Pipeline │
|
|
17
|
+
└────────────────────┬────────────────────────────────────┘
|
|
18
|
+
│
|
|
19
|
+
┌────────────────────▼────────────────────────────────────┐
|
|
20
|
+
│ Pipeline Orchestrator (NEW) │
|
|
21
|
+
│ - CDK Synthesis │
|
|
22
|
+
│ - Multi-Stack Handling │
|
|
23
|
+
│ - Configuration Loading │
|
|
24
|
+
└────────┬──────────────────────────────┬─────────────────┘
|
|
25
|
+
│ │
|
|
26
|
+
┌────▼────┐ ┌────▼────────┐
|
|
27
|
+
│Synthesis│ │Configuration│
|
|
28
|
+
│Manager │ │Manager (NEW)│
|
|
29
|
+
│(NEW) │ └─────────────┘
|
|
30
|
+
└────┬────┘
|
|
31
|
+
│
|
|
32
|
+
┌────────▼────────────────────────────────────────────────┐
|
|
33
|
+
│ Cost Analyzer (Enhanced) │
|
|
34
|
+
└────┬────────┬──────────┬──────────┬─────────────────────┘
|
|
35
|
+
│ │ │ │
|
|
36
|
+
┌────▼───┐┌──▼──┐ ┌────▼────┐ ┌──▼──────┐
|
|
37
|
+
│Parser ││Diff │ │Pricing │ │Reporter │
|
|
38
|
+
│ ││ │ │Service │ │ │
|
|
39
|
+
└────────┘└─────┘ │(Enhanced)│ └─────────┘
|
|
40
|
+
└────┬─────┘
|
|
41
|
+
│
|
|
42
|
+
┌────▼────────────────┐
|
|
43
|
+
│Resource Calculators │
|
|
44
|
+
│- Existing (8 types) │
|
|
45
|
+
│- NAT Gateway (NEW) │
|
|
46
|
+
│- ALB/NLB (NEW) │
|
|
47
|
+
│- CloudFront (NEW) │
|
|
48
|
+
│- ElastiCache (NEW) │
|
|
49
|
+
│- VPC Endpoint (NEW) │
|
|
50
|
+
└─────────────────────┘
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### New Components
|
|
54
|
+
|
|
55
|
+
1. **Pipeline Orchestrator**: Coordinates CDK synthesis, configuration loading, and cost analysis
|
|
56
|
+
2. **Synthesis Manager**: Handles CDK synthesis for base and target branches
|
|
57
|
+
3. **Configuration Manager**: Loads and validates project-specific configuration
|
|
58
|
+
4. **Threshold Enforcer**: Evaluates cost deltas against configured thresholds
|
|
59
|
+
5. **Additional Resource Calculators**: Support for 5 new resource types
|
|
60
|
+
|
|
61
|
+
## Components and Interfaces
|
|
62
|
+
|
|
63
|
+
### 1. Pipeline Orchestrator
|
|
64
|
+
|
|
65
|
+
**Purpose**: Coordinate the complete pipeline workflow including synthesis and analysis
|
|
66
|
+
|
|
67
|
+
**Interface**:
|
|
68
|
+
```typescript
|
|
69
|
+
interface PipelineOrchestrator {
|
|
70
|
+
runPipelineAnalysis(options: PipelineOptions): Promise<PipelineResult>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface PipelineOptions {
|
|
74
|
+
baseBranch: string;
|
|
75
|
+
targetBranch: string;
|
|
76
|
+
cdkAppPath?: string;
|
|
77
|
+
configPath?: string;
|
|
78
|
+
region?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface PipelineResult {
|
|
82
|
+
costAnalysis: CostAnalysisResult;
|
|
83
|
+
thresholdStatus: ThresholdStatus;
|
|
84
|
+
synthesisInfo: SynthesisInfo;
|
|
85
|
+
configUsed: ConfigSummary;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface ThresholdStatus {
|
|
89
|
+
passed: boolean;
|
|
90
|
+
thresholdType: 'none' | 'warning' | 'error';
|
|
91
|
+
configuredThreshold?: number;
|
|
92
|
+
actualDelta: number;
|
|
93
|
+
message: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface SynthesisInfo {
|
|
97
|
+
baseStackCount: number;
|
|
98
|
+
targetStackCount: number;
|
|
99
|
+
baseSynthesisTime: number;
|
|
100
|
+
targetSynthesisTime: number;
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Implementation Notes**:
|
|
105
|
+
- Orchestrates the complete workflow: config → synthesis → analysis → threshold check
|
|
106
|
+
- Handles errors at each stage with clear error messages
|
|
107
|
+
- Provides detailed result object for pipeline reporting
|
|
108
|
+
- Supports both single-stack and multi-stack applications
|
|
109
|
+
|
|
110
|
+
### 2. Synthesis Manager
|
|
111
|
+
|
|
112
|
+
**Purpose**: Execute CDK synthesis for base and target branches
|
|
113
|
+
|
|
114
|
+
**Interface**:
|
|
115
|
+
```typescript
|
|
116
|
+
interface SynthesisManager {
|
|
117
|
+
synthesizeBranch(options: SynthesisOptions): Promise<SynthesisResult>;
|
|
118
|
+
synthesizeMultiStack(options: SynthesisOptions): Promise<MultiStackResult>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface SynthesisOptions {
|
|
122
|
+
branch: string;
|
|
123
|
+
cdkAppPath: string;
|
|
124
|
+
outputPath?: string;
|
|
125
|
+
context?: Record<string, string>;
|
|
126
|
+
customCommand?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface SynthesisResult {
|
|
130
|
+
success: boolean;
|
|
131
|
+
templatePath: string;
|
|
132
|
+
stackName: string;
|
|
133
|
+
error?: string;
|
|
134
|
+
duration: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface MultiStackResult {
|
|
138
|
+
success: boolean;
|
|
139
|
+
stacks: SynthesisResult[];
|
|
140
|
+
totalDuration: number;
|
|
141
|
+
error?: string;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Implementation Notes**:
|
|
146
|
+
- Execute `cdk synth` command with proper error handling
|
|
147
|
+
- Support custom synthesis commands for complex setups
|
|
148
|
+
- Detect and handle multi-stack applications
|
|
149
|
+
- Capture CDK error output for debugging
|
|
150
|
+
- Clean up temporary files after synthesis
|
|
151
|
+
- Support passing CDK context values
|
|
152
|
+
|
|
153
|
+
### 3. Configuration Manager
|
|
154
|
+
|
|
155
|
+
**Purpose**: Load and validate project-specific configuration
|
|
156
|
+
|
|
157
|
+
**Interface**:
|
|
158
|
+
```typescript
|
|
159
|
+
interface ConfigurationManager {
|
|
160
|
+
loadConfig(configPath?: string): Promise<CostAnalyzerConfig>;
|
|
161
|
+
validateConfig(config: CostAnalyzerConfig): ValidationResult;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface CostAnalyzerConfig {
|
|
165
|
+
thresholds?: ThresholdConfig;
|
|
166
|
+
usageAssumptions?: UsageAssumptionsConfig;
|
|
167
|
+
synthesis?: SynthesisConfig;
|
|
168
|
+
exclusions?: ExclusionsConfig;
|
|
169
|
+
cache?: CacheConfig;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface ThresholdConfig {
|
|
173
|
+
default?: ThresholdLevels;
|
|
174
|
+
environments?: Record<string, ThresholdLevels>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface ThresholdLevels {
|
|
178
|
+
warning?: number;
|
|
179
|
+
error?: number;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface UsageAssumptionsConfig {
|
|
183
|
+
's3'?: {
|
|
184
|
+
storageGB?: number;
|
|
185
|
+
getRequests?: number;
|
|
186
|
+
putRequests?: number;
|
|
187
|
+
};
|
|
188
|
+
'lambda'?: {
|
|
189
|
+
invocationsPerMonth?: number;
|
|
190
|
+
averageDurationMs?: number;
|
|
191
|
+
};
|
|
192
|
+
'natGateway'?: {
|
|
193
|
+
dataProcessedGB?: number;
|
|
194
|
+
};
|
|
195
|
+
'alb'?: {
|
|
196
|
+
newConnectionsPerSecond?: number;
|
|
197
|
+
activeConnectionsPerMinute?: number;
|
|
198
|
+
processedBytesGB?: number;
|
|
199
|
+
};
|
|
200
|
+
'cloudfront'?: {
|
|
201
|
+
dataTransferGB?: number;
|
|
202
|
+
requests?: number;
|
|
203
|
+
};
|
|
204
|
+
// ... other resource types
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
interface SynthesisConfig {
|
|
208
|
+
appPath?: string;
|
|
209
|
+
outputPath?: string;
|
|
210
|
+
customCommand?: string;
|
|
211
|
+
context?: Record<string, string>;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
interface ExclusionsConfig {
|
|
215
|
+
resourceTypes?: string[];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
interface CacheConfig {
|
|
219
|
+
enabled?: boolean;
|
|
220
|
+
durationHours?: number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface ValidationResult {
|
|
224
|
+
valid: boolean;
|
|
225
|
+
errors: string[];
|
|
226
|
+
warnings: string[];
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Implementation Notes**:
|
|
231
|
+
- Support YAML and JSON configuration files
|
|
232
|
+
- Default file name: `.cdk-cost-analyzer.yml` or `.cdk-cost-analyzer.json`
|
|
233
|
+
- Validate configuration schema
|
|
234
|
+
- Provide helpful error messages for invalid configuration
|
|
235
|
+
- Support environment variable substitution in config values
|
|
236
|
+
- Merge configuration with defaults
|
|
237
|
+
|
|
238
|
+
### 4. Threshold Enforcer
|
|
239
|
+
|
|
240
|
+
**Purpose**: Evaluate cost deltas against configured thresholds
|
|
241
|
+
|
|
242
|
+
**Interface**:
|
|
243
|
+
```typescript
|
|
244
|
+
interface ThresholdEnforcer {
|
|
245
|
+
evaluateThreshold(
|
|
246
|
+
costDelta: number,
|
|
247
|
+
config: ThresholdConfig,
|
|
248
|
+
environment?: string
|
|
249
|
+
): ThresholdEvaluation;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
interface ThresholdEvaluation {
|
|
253
|
+
passed: boolean;
|
|
254
|
+
level: 'none' | 'warning' | 'error';
|
|
255
|
+
threshold?: number;
|
|
256
|
+
delta: number;
|
|
257
|
+
message: string;
|
|
258
|
+
recommendations: string[];
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Implementation Notes**:
|
|
263
|
+
- Support warning and error threshold levels
|
|
264
|
+
- Environment-specific threshold selection
|
|
265
|
+
- Generate actionable messages for threshold violations
|
|
266
|
+
- Identify top cost contributors when threshold exceeded
|
|
267
|
+
- Suggest optimization opportunities
|
|
268
|
+
|
|
269
|
+
### 5. Enhanced Resource Calculators
|
|
270
|
+
|
|
271
|
+
**Purpose**: Calculate costs for additional AWS resource types
|
|
272
|
+
|
|
273
|
+
#### NAT Gateway Calculator
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
interface NatGatewayCalculator extends ResourceCostCalculator {
|
|
277
|
+
supports(resourceType: string): boolean; // AWS::EC2::NatGateway
|
|
278
|
+
calculateCost(resource: Resource, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Cost Components**:
|
|
283
|
+
- Hourly rate: 730 hours/month
|
|
284
|
+
- Data processing: Default 100 GB/month (configurable)
|
|
285
|
+
|
|
286
|
+
#### Application Load Balancer Calculator
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
interface ALBCalculator extends ResourceCostCalculator {
|
|
290
|
+
supports(resourceType: string): boolean; // AWS::ElasticLoadBalancingV2::LoadBalancer (type: application)
|
|
291
|
+
calculateCost(resource: Resource, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Cost Components**:
|
|
296
|
+
- Hourly rate: 730 hours/month
|
|
297
|
+
- Load Balancer Capacity Units (LCUs): Based on default assumptions
|
|
298
|
+
- New connections: 25/second
|
|
299
|
+
- Active connections: 3000/minute
|
|
300
|
+
- Processed bytes: 100 GB/month
|
|
301
|
+
|
|
302
|
+
#### CloudFront Calculator
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
interface CloudFrontCalculator extends ResourceCostCalculator {
|
|
306
|
+
supports(resourceType: string): boolean; // AWS::CloudFront::Distribution
|
|
307
|
+
calculateCost(resource: Resource, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Cost Components**:
|
|
312
|
+
- Data transfer out: Default 100 GB/month (configurable)
|
|
313
|
+
- HTTP/HTTPS requests: Default 1M requests/month (configurable)
|
|
314
|
+
|
|
315
|
+
#### ElastiCache Calculator
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
interface ElastiCacheCalculator extends ResourceCostCalculator {
|
|
319
|
+
supports(resourceType: string): boolean; // AWS::ElastiCache::CacheCluster
|
|
320
|
+
calculateCost(resource: Resource, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Cost Components**:
|
|
325
|
+
- Node hourly rate × node count × 730 hours/month
|
|
326
|
+
- Support for Redis and Memcached
|
|
327
|
+
- Multi-AZ replica costs when configured
|
|
328
|
+
|
|
329
|
+
#### VPC Endpoint Calculator
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
interface VPCEndpointCalculator extends ResourceCostCalculator {
|
|
333
|
+
supports(resourceType: string): boolean; // AWS::EC2::VPCEndpoint
|
|
334
|
+
calculateCost(resource: Resource, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**Cost Components**:
|
|
339
|
+
- Interface endpoints: Hourly rate + data processing (default 100 GB/month)
|
|
340
|
+
- Gateway endpoints: $0 (no charge for S3 and DynamoDB)
|
|
341
|
+
|
|
342
|
+
## Data Models
|
|
343
|
+
|
|
344
|
+
### Configuration File Schema
|
|
345
|
+
|
|
346
|
+
```yaml
|
|
347
|
+
# .cdk-cost-analyzer.yml
|
|
348
|
+
|
|
349
|
+
# Cost thresholds
|
|
350
|
+
thresholds:
|
|
351
|
+
default:
|
|
352
|
+
warning: 50 # USD per month
|
|
353
|
+
error: 200 # USD per month
|
|
354
|
+
environments:
|
|
355
|
+
production:
|
|
356
|
+
warning: 25
|
|
357
|
+
error: 100
|
|
358
|
+
development:
|
|
359
|
+
warning: 100
|
|
360
|
+
error: 500
|
|
361
|
+
|
|
362
|
+
# Custom usage assumptions
|
|
363
|
+
usageAssumptions:
|
|
364
|
+
s3:
|
|
365
|
+
storageGB: 500
|
|
366
|
+
getRequests: 100000
|
|
367
|
+
putRequests: 10000
|
|
368
|
+
lambda:
|
|
369
|
+
invocationsPerMonth: 5000000
|
|
370
|
+
averageDurationMs: 500
|
|
371
|
+
natGateway:
|
|
372
|
+
dataProcessedGB: 500
|
|
373
|
+
alb:
|
|
374
|
+
newConnectionsPerSecond: 50
|
|
375
|
+
activeConnectionsPerMinute: 5000
|
|
376
|
+
processedBytesGB: 1000
|
|
377
|
+
cloudfront:
|
|
378
|
+
dataTransferGB: 1000
|
|
379
|
+
requests: 10000000
|
|
380
|
+
|
|
381
|
+
# CDK synthesis configuration
|
|
382
|
+
synthesis:
|
|
383
|
+
appPath: ./infrastructure
|
|
384
|
+
outputPath: ./cdk.out
|
|
385
|
+
context:
|
|
386
|
+
environment: production
|
|
387
|
+
region: eu-central-1
|
|
388
|
+
|
|
389
|
+
# Resource exclusions
|
|
390
|
+
exclusions:
|
|
391
|
+
resourceTypes:
|
|
392
|
+
- AWS::IAM::Role
|
|
393
|
+
- AWS::IAM::Policy
|
|
394
|
+
- AWS::Logs::LogGroup
|
|
395
|
+
|
|
396
|
+
# Cache configuration
|
|
397
|
+
cache:
|
|
398
|
+
enabled: true
|
|
399
|
+
durationHours: 24
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### GitLab CI Pipeline Configuration
|
|
403
|
+
|
|
404
|
+
```yaml
|
|
405
|
+
# .gitlab-ci.yml
|
|
406
|
+
|
|
407
|
+
stages:
|
|
408
|
+
- build
|
|
409
|
+
- test
|
|
410
|
+
- cost-analysis
|
|
411
|
+
- deploy
|
|
412
|
+
|
|
413
|
+
variables:
|
|
414
|
+
AWS_REGION: eu-central-1
|
|
415
|
+
CDK_APP_PATH: ./infrastructure
|
|
416
|
+
|
|
417
|
+
# Install dependencies
|
|
418
|
+
install:
|
|
419
|
+
stage: build
|
|
420
|
+
script:
|
|
421
|
+
- npm ci
|
|
422
|
+
- cd $CDK_APP_PATH && npm ci
|
|
423
|
+
cache:
|
|
424
|
+
paths:
|
|
425
|
+
- node_modules/
|
|
426
|
+
- $CDK_APP_PATH/node_modules/
|
|
427
|
+
artifacts:
|
|
428
|
+
paths:
|
|
429
|
+
- node_modules/
|
|
430
|
+
- $CDK_APP_PATH/node_modules/
|
|
431
|
+
expire_in: 1 hour
|
|
432
|
+
|
|
433
|
+
# Cost analysis for merge requests
|
|
434
|
+
cost-analysis:
|
|
435
|
+
stage: cost-analysis
|
|
436
|
+
image: node:18
|
|
437
|
+
dependencies:
|
|
438
|
+
- install
|
|
439
|
+
before_script:
|
|
440
|
+
- npm install -g cdk-cost-analyzer
|
|
441
|
+
script:
|
|
442
|
+
# Run cost analysis with automatic synthesis
|
|
443
|
+
- |
|
|
444
|
+
cdk-cost-analyzer pipeline \
|
|
445
|
+
--base-branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME \
|
|
446
|
+
--target-branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME \
|
|
447
|
+
--cdk-app-path $CDK_APP_PATH \
|
|
448
|
+
--region $AWS_REGION \
|
|
449
|
+
--format markdown \
|
|
450
|
+
--post-to-gitlab
|
|
451
|
+
cache:
|
|
452
|
+
key: pricing-cache
|
|
453
|
+
paths:
|
|
454
|
+
- .cdk-cost-analyzer-cache/
|
|
455
|
+
only:
|
|
456
|
+
- merge_requests
|
|
457
|
+
allow_failure: false # Fail pipeline if cost threshold exceeded
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
## Correctness Properties
|
|
461
|
+
|
|
462
|
+
*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.*
|
|
463
|
+
|
|
464
|
+
Property 1: CDK synthesis produces valid CloudFormation templates
|
|
465
|
+
*For any* valid CDK application, synthesis should produce CloudFormation templates that can be parsed by the template parser without errors.
|
|
466
|
+
**Validates: Requirements 1.1, 1.2, 1.3**
|
|
467
|
+
|
|
468
|
+
Property 2: Multi-stack cost aggregation equals sum of individual stacks
|
|
469
|
+
*For any* multi-stack CDK application, the total cost delta should equal the sum of cost deltas across all individual stacks.
|
|
470
|
+
**Validates: Requirements 2.4**
|
|
471
|
+
|
|
472
|
+
Property 3: Configuration file validation catches invalid schemas
|
|
473
|
+
*For any* configuration file with invalid schema, the configuration manager should reject it with descriptive error messages before analysis begins.
|
|
474
|
+
**Validates: Requirements 6.5**
|
|
475
|
+
|
|
476
|
+
Property 4: Threshold evaluation is consistent
|
|
477
|
+
*For any* cost delta and threshold configuration, evaluating the threshold multiple times should produce the same result.
|
|
478
|
+
**Validates: Requirements 4.1, 4.2, 4.3**
|
|
479
|
+
|
|
480
|
+
Property 5: Custom usage assumptions override defaults
|
|
481
|
+
*For any* resource type with custom usage assumptions configured, the cost calculation should use the custom values instead of defaults.
|
|
482
|
+
**Validates: Requirements 6.2, 6.3**
|
|
483
|
+
|
|
484
|
+
Property 6: Resource exclusions are respected
|
|
485
|
+
*For any* resource type in the exclusions list, that resource should not appear in the cost analysis results.
|
|
486
|
+
**Validates: Requirements 15.1, 15.2, 15.3**
|
|
487
|
+
|
|
488
|
+
Property 7: Environment-specific thresholds are applied correctly
|
|
489
|
+
*For any* environment with specific threshold configuration, the system should apply that environment's threshold instead of the default.
|
|
490
|
+
**Validates: Requirements 19.1, 19.2, 19.3**
|
|
491
|
+
|
|
492
|
+
Property 8: NAT Gateway costs include all components
|
|
493
|
+
*For any* NAT Gateway resource, the calculated cost should include both hourly charges and data processing charges.
|
|
494
|
+
**Validates: Requirements 7.1, 7.2, 7.3**
|
|
495
|
+
|
|
496
|
+
Property 9: ALB costs scale with LCU assumptions
|
|
497
|
+
*For any* two ALB configurations where one has higher LCU assumptions, the higher LCU configuration should have equal or higher estimated cost.
|
|
498
|
+
**Validates: Requirements 8.1, 8.2, 8.3**
|
|
499
|
+
|
|
500
|
+
Property 10: Gateway VPC endpoints have zero cost
|
|
501
|
+
*For any* VPC endpoint of type Gateway for S3 or DynamoDB, the calculated cost should be zero.
|
|
502
|
+
**Validates: Requirements 11.3**
|
|
503
|
+
|
|
504
|
+
Property 11: Synthesis errors are captured and reported
|
|
505
|
+
*For any* CDK synthesis failure, the error output should be captured and included in the error message displayed to the user.
|
|
506
|
+
**Validates: Requirements 13.1, 13.2, 13.3**
|
|
507
|
+
|
|
508
|
+
Property 12: Missing AWS credentials are detected early
|
|
509
|
+
*For any* execution without AWS credentials configured, the system should detect this before attempting synthesis or pricing API calls.
|
|
510
|
+
**Validates: Requirements 12.1, 12.2, 12.3**
|
|
511
|
+
|
|
512
|
+
Property 13: Cache reduces API calls
|
|
513
|
+
*For any* pricing query where cached data exists and is fresh, the system should use cached data instead of making an API call.
|
|
514
|
+
**Validates: Requirements 20.2, 20.3**
|
|
515
|
+
|
|
516
|
+
Property 14: Configuration summary reflects actual settings
|
|
517
|
+
*For any* cost analysis result, the configuration summary should accurately reflect all settings that were applied during analysis.
|
|
518
|
+
**Validates: Requirements 16.1, 16.2, 16.3, 16.4**
|
|
519
|
+
|
|
520
|
+
Property 15: Threshold violations include actionable guidance
|
|
521
|
+
*For any* threshold violation, the system should provide specific next steps and identify the resources contributing most to the cost increase.
|
|
522
|
+
**Validates: Requirements 17.1, 17.2, 17.3, 17.4**
|
|
523
|
+
|
|
524
|
+
## Error Handling
|
|
525
|
+
|
|
526
|
+
### Enhanced Error Categories
|
|
527
|
+
|
|
528
|
+
1. **Synthesis Errors**
|
|
529
|
+
- CDK synthesis command failures
|
|
530
|
+
- Missing CDK dependencies
|
|
531
|
+
- Invalid CDK application code
|
|
532
|
+
- Missing CDK context values
|
|
533
|
+
|
|
534
|
+
2. **Configuration Errors**
|
|
535
|
+
- Invalid configuration file syntax
|
|
536
|
+
- Invalid configuration schema
|
|
537
|
+
- Missing required configuration values
|
|
538
|
+
- Invalid threshold values
|
|
539
|
+
|
|
540
|
+
3. **Credential Errors**
|
|
541
|
+
- Missing AWS credentials
|
|
542
|
+
- Invalid AWS credentials
|
|
543
|
+
- Insufficient IAM permissions
|
|
544
|
+
|
|
545
|
+
4. **Pipeline Errors**
|
|
546
|
+
- Git checkout failures
|
|
547
|
+
- Branch not found
|
|
548
|
+
- Merge conflicts during checkout
|
|
549
|
+
|
|
550
|
+
### Error Handling Strategy
|
|
551
|
+
|
|
552
|
+
**Synthesis Errors**: Fail fast with CDK output
|
|
553
|
+
- Capture complete CDK error output
|
|
554
|
+
- Indicate which branch failed (base or target)
|
|
555
|
+
- Suggest common fixes (install dependencies, fix syntax)
|
|
556
|
+
- Exit with non-zero status code
|
|
557
|
+
|
|
558
|
+
**Configuration Errors**: Validate early
|
|
559
|
+
- Validate configuration before synthesis
|
|
560
|
+
- Provide line numbers for syntax errors
|
|
561
|
+
- Suggest correct configuration format
|
|
562
|
+
- Exit with non-zero status code
|
|
563
|
+
|
|
564
|
+
**Credential Errors**: Detect before API calls
|
|
565
|
+
- Check for credentials before synthesis
|
|
566
|
+
- Provide setup instructions for GitLab CI
|
|
567
|
+
- Link to AWS credential configuration docs
|
|
568
|
+
- Exit with non-zero status code
|
|
569
|
+
|
|
570
|
+
**Pipeline Errors**: Provide context
|
|
571
|
+
- Show git command that failed
|
|
572
|
+
- Suggest checking branch names
|
|
573
|
+
- Provide GitLab CI troubleshooting steps
|
|
574
|
+
- Exit with non-zero status code
|
|
575
|
+
|
|
576
|
+
### Error Messages
|
|
577
|
+
|
|
578
|
+
```typescript
|
|
579
|
+
class SynthesisError extends Error {
|
|
580
|
+
constructor(
|
|
581
|
+
message: string,
|
|
582
|
+
public branch: string,
|
|
583
|
+
public cdkOutput: string
|
|
584
|
+
) {
|
|
585
|
+
super(message);
|
|
586
|
+
this.name = 'SynthesisError';
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
class ConfigurationError extends Error {
|
|
591
|
+
constructor(
|
|
592
|
+
message: string,
|
|
593
|
+
public configPath: string,
|
|
594
|
+
public validationErrors: string[]
|
|
595
|
+
) {
|
|
596
|
+
super(message);
|
|
597
|
+
this.name = 'ConfigurationError';
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
class CredentialError extends Error {
|
|
602
|
+
constructor(message: string, public setupInstructions: string) {
|
|
603
|
+
super(message);
|
|
604
|
+
this.name = 'CredentialError';
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
class ThresholdExceededError extends Error {
|
|
609
|
+
constructor(
|
|
610
|
+
message: string,
|
|
611
|
+
public threshold: number,
|
|
612
|
+
public actualDelta: number,
|
|
613
|
+
public topContributors: ResourceCost[]
|
|
614
|
+
) {
|
|
615
|
+
super(message);
|
|
616
|
+
this.name = 'ThresholdExceededError';
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
## Testing Strategy
|
|
622
|
+
|
|
623
|
+
### Unit Testing
|
|
624
|
+
|
|
625
|
+
**Synthesis Manager Tests**:
|
|
626
|
+
- Execute successful CDK synthesis
|
|
627
|
+
- Handle synthesis failures
|
|
628
|
+
- Detect multi-stack applications
|
|
629
|
+
- Pass custom context values
|
|
630
|
+
- Clean up temporary files
|
|
631
|
+
|
|
632
|
+
**Configuration Manager Tests**:
|
|
633
|
+
- Load valid YAML configuration
|
|
634
|
+
- Load valid JSON configuration
|
|
635
|
+
- Reject invalid configuration schema
|
|
636
|
+
- Merge configuration with defaults
|
|
637
|
+
- Handle missing configuration file
|
|
638
|
+
|
|
639
|
+
**Threshold Enforcer Tests**:
|
|
640
|
+
- Evaluate warning thresholds
|
|
641
|
+
- Evaluate error thresholds
|
|
642
|
+
- Select environment-specific thresholds
|
|
643
|
+
- Generate actionable messages
|
|
644
|
+
- Identify top cost contributors
|
|
645
|
+
|
|
646
|
+
**Resource Calculator Tests**:
|
|
647
|
+
- Calculate NAT Gateway costs
|
|
648
|
+
- Calculate ALB costs with LCU components
|
|
649
|
+
- Calculate CloudFront costs
|
|
650
|
+
- Calculate ElastiCache costs for Redis and Memcached
|
|
651
|
+
- Calculate VPC Endpoint costs (interface vs gateway)
|
|
652
|
+
|
|
653
|
+
### Property-Based Testing
|
|
654
|
+
|
|
655
|
+
**Synthesis Properties**:
|
|
656
|
+
- Property 1: CDK synthesis produces valid CloudFormation templates (Requirements 1.1, 1.2, 1.3)
|
|
657
|
+
|
|
658
|
+
**Multi-Stack Properties**:
|
|
659
|
+
- Property 2: Multi-stack cost aggregation equals sum of individual stacks (Requirements 2.4)
|
|
660
|
+
|
|
661
|
+
**Configuration Properties**:
|
|
662
|
+
- Property 3: Configuration file validation catches invalid schemas (Requirements 6.5)
|
|
663
|
+
- Property 5: Custom usage assumptions override defaults (Requirements 6.2, 6.3)
|
|
664
|
+
- Property 6: Resource exclusions are respected (Requirements 15.1, 15.2, 15.3)
|
|
665
|
+
- Property 7: Environment-specific thresholds are applied correctly (Requirements 19.1, 19.2, 19.3)
|
|
666
|
+
|
|
667
|
+
**Threshold Properties**:
|
|
668
|
+
- Property 4: Threshold evaluation is consistent (Requirements 4.1, 4.2, 4.3)
|
|
669
|
+
- Property 15: Threshold violations include actionable guidance (Requirements 17.1, 17.2, 17.3, 17.4)
|
|
670
|
+
|
|
671
|
+
**Resource Calculator Properties**:
|
|
672
|
+
- Property 8: NAT Gateway costs include all components (Requirements 7.1, 7.2, 7.3)
|
|
673
|
+
- Property 9: ALB costs scale with LCU assumptions (Requirements 8.1, 8.2, 8.3)
|
|
674
|
+
- Property 10: Gateway VPC endpoints have zero cost (Requirements 11.3)
|
|
675
|
+
|
|
676
|
+
**Error Handling Properties**:
|
|
677
|
+
- Property 11: Synthesis errors are captured and reported (Requirements 13.1, 13.2, 13.3)
|
|
678
|
+
- Property 12: Missing AWS credentials are detected early (Requirements 12.1, 12.2, 12.3)
|
|
679
|
+
|
|
680
|
+
**Cache Properties**:
|
|
681
|
+
- Property 13: Cache reduces API calls (Requirements 20.2, 20.3)
|
|
682
|
+
|
|
683
|
+
**Reporting Properties**:
|
|
684
|
+
- Property 14: Configuration summary reflects actual settings (Requirements 16.1, 16.2, 16.3, 16.4)
|
|
685
|
+
|
|
686
|
+
### Integration Testing
|
|
687
|
+
|
|
688
|
+
**End-to-End Pipeline Tests**:
|
|
689
|
+
- Complete pipeline with single-stack CDK app
|
|
690
|
+
- Complete pipeline with multi-stack CDK app
|
|
691
|
+
- Pipeline with threshold enforcement
|
|
692
|
+
- Pipeline with custom configuration
|
|
693
|
+
- Pipeline with synthesis failures
|
|
694
|
+
|
|
695
|
+
**GitLab CI Tests**:
|
|
696
|
+
- Test with GitLab CI environment variables
|
|
697
|
+
- Test credential configuration in CI
|
|
698
|
+
- Test cache persistence across pipeline runs
|
|
699
|
+
|
|
700
|
+
## Dependencies
|
|
701
|
+
|
|
702
|
+
### New Production Dependencies
|
|
703
|
+
|
|
704
|
+
- **yaml**: YAML configuration file parsing (alternative: use js-yaml already included)
|
|
705
|
+
- **simple-git**: Git operations for branch checkout (if implementing in-tool)
|
|
706
|
+
|
|
707
|
+
### Existing Dependencies (No Changes)
|
|
708
|
+
|
|
709
|
+
- **@aws-sdk/client-pricing**: AWS Pricing API client
|
|
710
|
+
- **js-yaml**: YAML template parsing
|
|
711
|
+
- **commander**: CLI argument parsing
|
|
712
|
+
|
|
713
|
+
### Development Dependencies (No Changes)
|
|
714
|
+
|
|
715
|
+
- **typescript**: TypeScript compiler
|
|
716
|
+
- **fast-check**: Property-based testing library
|
|
717
|
+
- **vitest**: Unit testing framework
|
|
718
|
+
|
|
719
|
+
## Implementation Notes
|
|
720
|
+
|
|
721
|
+
### CDK Synthesis Approach
|
|
722
|
+
|
|
723
|
+
Two implementation options:
|
|
724
|
+
|
|
725
|
+
**Option 1: External Synthesis (Recommended)**
|
|
726
|
+
- Require users to synthesize before running cost analyzer
|
|
727
|
+
- Simpler implementation, fewer dependencies
|
|
728
|
+
- Better separation of concerns
|
|
729
|
+
- Users run: `cdk synth` then `cdk-cost-analyzer`
|
|
730
|
+
|
|
731
|
+
**Option 2: Integrated Synthesis**
|
|
732
|
+
- Tool executes `cdk synth` internally
|
|
733
|
+
- More complex, requires git operations
|
|
734
|
+
- Better developer experience
|
|
735
|
+
- Single command: `cdk-cost-analyzer pipeline`
|
|
736
|
+
|
|
737
|
+
**Recommendation**: Start with Option 1 for MVP, add Option 2 based on user feedback.
|
|
738
|
+
|
|
739
|
+
### Configuration File Discovery
|
|
740
|
+
|
|
741
|
+
Search order:
|
|
742
|
+
1. Path specified via `--config` flag
|
|
743
|
+
2. `.cdk-cost-analyzer.yml` in current directory
|
|
744
|
+
3. `.cdk-cost-analyzer.json` in current directory
|
|
745
|
+
4. `.cdk-cost-analyzer.yml` in CDK app directory
|
|
746
|
+
5. No configuration (use defaults)
|
|
747
|
+
|
|
748
|
+
### Threshold Enforcement in GitLab CI
|
|
749
|
+
|
|
750
|
+
Exit codes:
|
|
751
|
+
- 0: Analysis successful, threshold not exceeded
|
|
752
|
+
- 1: Analysis failed (synthesis error, API error, etc.)
|
|
753
|
+
- 2: Analysis successful, but threshold exceeded
|
|
754
|
+
|
|
755
|
+
GitLab CI configuration:
|
|
756
|
+
```yaml
|
|
757
|
+
cost-analysis:
|
|
758
|
+
script:
|
|
759
|
+
- cdk-cost-analyzer pipeline ...
|
|
760
|
+
allow_failure: false # Fail pipeline on threshold exceeded
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
### Cache Implementation
|
|
764
|
+
|
|
765
|
+
Use GitLab CI cache:
|
|
766
|
+
```yaml
|
|
767
|
+
cache:
|
|
768
|
+
key: pricing-cache-${CI_COMMIT_REF_SLUG}
|
|
769
|
+
paths:
|
|
770
|
+
- .cdk-cost-analyzer-cache/
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
Cache structure:
|
|
774
|
+
```
|
|
775
|
+
.cdk-cost-analyzer-cache/
|
|
776
|
+
pricing/
|
|
777
|
+
ec2-eu-central-1.json
|
|
778
|
+
s3-eu-central-1.json
|
|
779
|
+
...
|
|
780
|
+
metadata.json # Cache timestamps
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
### Performance Considerations
|
|
784
|
+
|
|
785
|
+
- Parallel synthesis of base and target branches (if implementing integrated synthesis)
|
|
786
|
+
- Parallel pricing queries for multiple resources (already implemented)
|
|
787
|
+
- Cache pricing data across pipeline runs
|
|
788
|
+
- Lazy loading of resource calculators
|
|
789
|
+
- Stream processing for large templates
|
|
790
|
+
|
|
791
|
+
### Security Considerations
|
|
792
|
+
|
|
793
|
+
- Never log AWS credentials
|
|
794
|
+
- Sanitize CDK error output (may contain sensitive values)
|
|
795
|
+
- Validate all configuration inputs
|
|
796
|
+
- Use read-only AWS credentials when possible
|
|
797
|
+
- Secure cache files (pricing data is not sensitive but should be validated)
|
|
798
|
+
|
|
799
|
+
## Migration Path
|
|
800
|
+
|
|
801
|
+
### For Existing Users
|
|
802
|
+
|
|
803
|
+
1. **No Breaking Changes**: All existing functionality continues to work
|
|
804
|
+
2. **Optional Configuration**: Configuration file is optional, defaults work as before
|
|
805
|
+
3. **Gradual Adoption**: Users can adopt new features incrementally
|
|
806
|
+
|
|
807
|
+
### Recommended Migration Steps
|
|
808
|
+
|
|
809
|
+
1. Update to new version
|
|
810
|
+
2. Test existing pipeline (should work unchanged)
|
|
811
|
+
3. Add configuration file for custom assumptions
|
|
812
|
+
4. Configure thresholds
|
|
813
|
+
5. Enable integrated synthesis (if implemented)
|
|
814
|
+
|
|
815
|
+
## Packaging and Distribution
|
|
816
|
+
|
|
817
|
+
### Package Management with Projen
|
|
818
|
+
|
|
819
|
+
Following CDK best practices and the Projen steering guidelines, the project should use Projen for package management and publishing.
|
|
820
|
+
|
|
821
|
+
**Important**: All project configuration should be managed through `.projenrc.ts`. Never manually edit generated files like `package.json`, `tsconfig.json`, or `.gitignore`. Always run `node ./projen.js` after modifying `.projenrc.ts` to regenerate project files.
|
|
822
|
+
|
|
823
|
+
**Projen Configuration**:
|
|
824
|
+
```typescript
|
|
825
|
+
// .projenrc.ts
|
|
826
|
+
import { typescript } from 'projen';
|
|
827
|
+
|
|
828
|
+
const project = new typescript.TypeScriptProject({
|
|
829
|
+
name: 'cdk-cost-analyzer',
|
|
830
|
+
description: 'Analyze AWS CDK infrastructure changes and provide cost impact summaries',
|
|
831
|
+
defaultReleaseBranch: 'main',
|
|
832
|
+
|
|
833
|
+
// Package metadata
|
|
834
|
+
packageName: 'cdk-cost-analyzer',
|
|
835
|
+
authorName: 'ANWB',
|
|
836
|
+
authorEmail: 'devops@anwb.nl',
|
|
837
|
+
license: 'MIT',
|
|
838
|
+
|
|
839
|
+
// Repository
|
|
840
|
+
repositoryUrl: 'https://gitlab.com/anwb/cdk-cost-analyzer.git',
|
|
841
|
+
|
|
842
|
+
// Publishing
|
|
843
|
+
releaseToNpm: true,
|
|
844
|
+
npmAccess: 'public', // or 'restricted' for private registry
|
|
845
|
+
|
|
846
|
+
// CLI binary
|
|
847
|
+
bin: {
|
|
848
|
+
'cdk-cost-analyzer': 'dist/cli/index.js',
|
|
849
|
+
},
|
|
850
|
+
|
|
851
|
+
// Dependencies
|
|
852
|
+
deps: [
|
|
853
|
+
'@aws-sdk/client-pricing@^3.705.0',
|
|
854
|
+
'commander@^12.1.0',
|
|
855
|
+
'js-yaml@^4.1.0',
|
|
856
|
+
],
|
|
857
|
+
|
|
858
|
+
devDeps: [
|
|
859
|
+
'@types/js-yaml@^4.0.9',
|
|
860
|
+
'@types/node@^22.10.1',
|
|
861
|
+
'fast-check@^3.23.1',
|
|
862
|
+
'vitest@^2.1.6',
|
|
863
|
+
],
|
|
864
|
+
|
|
865
|
+
// Build configuration
|
|
866
|
+
tsconfig: {
|
|
867
|
+
compilerOptions: {
|
|
868
|
+
target: 'ES2020',
|
|
869
|
+
module: 'commonjs',
|
|
870
|
+
lib: ['ES2020'],
|
|
871
|
+
declaration: true,
|
|
872
|
+
outDir: 'dist',
|
|
873
|
+
rootDir: 'src',
|
|
874
|
+
strict: true,
|
|
875
|
+
esModuleInterop: true,
|
|
876
|
+
skipLibCheck: true,
|
|
877
|
+
forceConsistentCasingInFileNames: true,
|
|
878
|
+
},
|
|
879
|
+
},
|
|
880
|
+
|
|
881
|
+
// Testing
|
|
882
|
+
jestOptions: {
|
|
883
|
+
jestConfig: {
|
|
884
|
+
testEnvironment: 'node',
|
|
885
|
+
testMatch: ['**/*.test.ts'],
|
|
886
|
+
collectCoverageFrom: ['src/**/*.ts'],
|
|
887
|
+
coverageThreshold: {
|
|
888
|
+
global: {
|
|
889
|
+
branches: 80,
|
|
890
|
+
functions: 80,
|
|
891
|
+
lines: 80,
|
|
892
|
+
statements: 80,
|
|
893
|
+
},
|
|
894
|
+
},
|
|
895
|
+
},
|
|
896
|
+
},
|
|
897
|
+
|
|
898
|
+
// GitHub Actions / GitLab CI
|
|
899
|
+
buildWorkflow: true,
|
|
900
|
+
release: true,
|
|
901
|
+
|
|
902
|
+
// Additional scripts
|
|
903
|
+
scripts: {
|
|
904
|
+
'synth': 'projen',
|
|
905
|
+
'test:integration': 'vitest run test/integration',
|
|
906
|
+
'test:e2e': 'vitest run test/e2e',
|
|
907
|
+
},
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
project.synth();
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
### Distribution Channels
|
|
914
|
+
|
|
915
|
+
**1. NPM Registry (Public)**
|
|
916
|
+
- Primary distribution channel
|
|
917
|
+
- Automatic publishing via GitLab CI on version tags
|
|
918
|
+
- Semantic versioning (semver)
|
|
919
|
+
- Changelog generation
|
|
920
|
+
|
|
921
|
+
**2. Private NPM Registry (Optional)**
|
|
922
|
+
- For ANWB-internal versions with custom features
|
|
923
|
+
- GitLab Package Registry integration
|
|
924
|
+
- Same package name with scoped namespace: `@anwb/cdk-cost-analyzer`
|
|
925
|
+
|
|
926
|
+
**3. Docker Image (Optional)**
|
|
927
|
+
- Pre-built image with all dependencies
|
|
928
|
+
- Useful for CI/CD environments
|
|
929
|
+
- Published to GitLab Container Registry
|
|
930
|
+
|
|
931
|
+
### Release Process
|
|
932
|
+
|
|
933
|
+
**Automated Release Pipeline**:
|
|
934
|
+
```yaml
|
|
935
|
+
# .gitlab-ci.yml
|
|
936
|
+
|
|
937
|
+
stages:
|
|
938
|
+
- test
|
|
939
|
+
- build
|
|
940
|
+
- release
|
|
941
|
+
|
|
942
|
+
# Run tests on all commits
|
|
943
|
+
test:
|
|
944
|
+
stage: test
|
|
945
|
+
image: node:18
|
|
946
|
+
script:
|
|
947
|
+
- npm ci
|
|
948
|
+
- npm run build
|
|
949
|
+
- npm test
|
|
950
|
+
- npm run lint
|
|
951
|
+
coverage: '/Lines\s*:\s*(\d+\.\d+)%/'
|
|
952
|
+
artifacts:
|
|
953
|
+
reports:
|
|
954
|
+
coverage_report:
|
|
955
|
+
coverage_format: cobertura
|
|
956
|
+
path: coverage/cobertura-coverage.xml
|
|
957
|
+
|
|
958
|
+
# Build package
|
|
959
|
+
build:
|
|
960
|
+
stage: build
|
|
961
|
+
image: node:18
|
|
962
|
+
script:
|
|
963
|
+
- npm ci
|
|
964
|
+
- npm run build
|
|
965
|
+
- npm pack
|
|
966
|
+
artifacts:
|
|
967
|
+
paths:
|
|
968
|
+
- '*.tgz'
|
|
969
|
+
expire_in: 1 week
|
|
970
|
+
only:
|
|
971
|
+
- tags
|
|
972
|
+
- main
|
|
973
|
+
|
|
974
|
+
# Publish to NPM
|
|
975
|
+
publish:npm:
|
|
976
|
+
stage: release
|
|
977
|
+
image: node:18
|
|
978
|
+
script:
|
|
979
|
+
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
|
|
980
|
+
- npm publish --access public
|
|
981
|
+
only:
|
|
982
|
+
- tags
|
|
983
|
+
when: manual
|
|
984
|
+
|
|
985
|
+
# Publish to GitLab Package Registry
|
|
986
|
+
publish:gitlab:
|
|
987
|
+
stage: release
|
|
988
|
+
image: node:18
|
|
989
|
+
script:
|
|
990
|
+
- echo "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" > .npmrc
|
|
991
|
+
- npm publish
|
|
992
|
+
only:
|
|
993
|
+
- tags
|
|
994
|
+
|
|
995
|
+
# Create GitHub/GitLab release
|
|
996
|
+
release:
|
|
997
|
+
stage: release
|
|
998
|
+
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
999
|
+
script:
|
|
1000
|
+
- echo "Creating release for ${CI_COMMIT_TAG}"
|
|
1001
|
+
release:
|
|
1002
|
+
tag_name: '${CI_COMMIT_TAG}'
|
|
1003
|
+
description: './CHANGELOG.md'
|
|
1004
|
+
only:
|
|
1005
|
+
- tags
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
### Versioning Strategy
|
|
1009
|
+
|
|
1010
|
+
**Semantic Versioning**:
|
|
1011
|
+
- **Major (X.0.0)**: Breaking changes to API or CLI
|
|
1012
|
+
- **Minor (0.X.0)**: New features, backward compatible
|
|
1013
|
+
- **Patch (0.0.X)**: Bug fixes, backward compatible
|
|
1014
|
+
|
|
1015
|
+
**Version Bumping with Projen**:
|
|
1016
|
+
```bash
|
|
1017
|
+
# Projen handles versioning automatically based on conventional commits
|
|
1018
|
+
# Manual version bump (if needed):
|
|
1019
|
+
node ./projen.js bump
|
|
1020
|
+
|
|
1021
|
+
# Or use npm version (Projen will sync)
|
|
1022
|
+
npm version patch -m "chore: release v%s"
|
|
1023
|
+
npm version minor -m "feat: release v%s"
|
|
1024
|
+
npm version major -m "feat!: release v%s"
|
|
1025
|
+
|
|
1026
|
+
# Push tags to trigger release
|
|
1027
|
+
git push --follow-tags
|
|
1028
|
+
```
|
|
1029
|
+
|
|
1030
|
+
**Note**: Projen can be configured to automatically bump versions based on conventional commit messages in the release workflow.
|
|
1031
|
+
|
|
1032
|
+
### Package Contents
|
|
1033
|
+
|
|
1034
|
+
**Files Included in Package**:
|
|
1035
|
+
```json
|
|
1036
|
+
{
|
|
1037
|
+
"files": [
|
|
1038
|
+
"dist/",
|
|
1039
|
+
"README.md",
|
|
1040
|
+
"LICENSE",
|
|
1041
|
+
"CHANGELOG.md"
|
|
1042
|
+
]
|
|
1043
|
+
}
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
**Excluded from Package**:
|
|
1047
|
+
- Source TypeScript files (only compiled JS)
|
|
1048
|
+
- Tests
|
|
1049
|
+
- Development configuration
|
|
1050
|
+
- CI/CD configuration
|
|
1051
|
+
- Documentation source files
|
|
1052
|
+
|
|
1053
|
+
### Installation Methods
|
|
1054
|
+
|
|
1055
|
+
**1. Global Installation (CLI Usage)**:
|
|
1056
|
+
```bash
|
|
1057
|
+
npm install -g cdk-cost-analyzer
|
|
1058
|
+
|
|
1059
|
+
# Use anywhere
|
|
1060
|
+
cdk-cost-analyzer base.json target.json
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
**2. Project Dependency (Programmatic Usage)**:
|
|
1064
|
+
```bash
|
|
1065
|
+
npm install --save-dev cdk-cost-analyzer
|
|
1066
|
+
|
|
1067
|
+
# Use in code
|
|
1068
|
+
import { analyzeCosts } from 'cdk-cost-analyzer';
|
|
1069
|
+
```
|
|
1070
|
+
|
|
1071
|
+
**3. npx (No Installation)**:
|
|
1072
|
+
```bash
|
|
1073
|
+
npx cdk-cost-analyzer base.json target.json
|
|
1074
|
+
```
|
|
1075
|
+
|
|
1076
|
+
**4. Docker Image**:
|
|
1077
|
+
```bash
|
|
1078
|
+
docker run -v $(pwd):/workspace \
|
|
1079
|
+
registry.gitlab.com/anwb/cdk-cost-analyzer:latest \
|
|
1080
|
+
cdk-cost-analyzer base.json target.json
|
|
1081
|
+
```
|
|
1082
|
+
|
|
1083
|
+
### Quality Gates
|
|
1084
|
+
|
|
1085
|
+
**Pre-Release Checks**:
|
|
1086
|
+
1. All tests pass (unit + property-based + integration)
|
|
1087
|
+
2. Code coverage > 80%
|
|
1088
|
+
3. No TypeScript errors
|
|
1089
|
+
4. No linting errors
|
|
1090
|
+
5. Documentation updated
|
|
1091
|
+
6. CHANGELOG updated
|
|
1092
|
+
7. Version bumped appropriately
|
|
1093
|
+
|
|
1094
|
+
**Automated Checks in CI with Projen**:
|
|
1095
|
+
```yaml
|
|
1096
|
+
quality-gates:
|
|
1097
|
+
stage: test
|
|
1098
|
+
script:
|
|
1099
|
+
# Use Projen tasks instead of npm directly
|
|
1100
|
+
- node ./projen.js build # Runs compile, test, and lint
|
|
1101
|
+
- node ./projen.js test:coverage
|
|
1102
|
+
- |
|
|
1103
|
+
COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
|
|
1104
|
+
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
|
|
1105
|
+
echo "Coverage $COVERAGE% is below 80%"
|
|
1106
|
+
exit 1
|
|
1107
|
+
fi
|
|
1108
|
+
only:
|
|
1109
|
+
- merge_requests
|
|
1110
|
+
- main
|
|
1111
|
+
```
|
|
1112
|
+
|
|
1113
|
+
**Important**: Always use `node ./projen.js <task>` instead of npm/yarn commands directly. Check `.projen/tasks.json` for available tasks.
|
|
1114
|
+
|
|
1115
|
+
### Distribution Artifacts
|
|
1116
|
+
|
|
1117
|
+
**NPM Package**:
|
|
1118
|
+
- Compiled JavaScript (CommonJS)
|
|
1119
|
+
- TypeScript type definitions (.d.ts)
|
|
1120
|
+
- Source maps
|
|
1121
|
+
- README and LICENSE
|
|
1122
|
+
|
|
1123
|
+
**Docker Image Layers**:
|
|
1124
|
+
```dockerfile
|
|
1125
|
+
FROM node:18-alpine
|
|
1126
|
+
|
|
1127
|
+
# Install dependencies
|
|
1128
|
+
WORKDIR /app
|
|
1129
|
+
COPY package*.json ./
|
|
1130
|
+
RUN npm ci --only=production
|
|
1131
|
+
|
|
1132
|
+
# Copy application
|
|
1133
|
+
COPY dist/ ./dist/
|
|
1134
|
+
|
|
1135
|
+
# Set up CLI
|
|
1136
|
+
RUN npm link
|
|
1137
|
+
|
|
1138
|
+
# Set working directory for user files
|
|
1139
|
+
WORKDIR /workspace
|
|
1140
|
+
|
|
1141
|
+
ENTRYPOINT ["cdk-cost-analyzer"]
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
### Changelog Management
|
|
1145
|
+
|
|
1146
|
+
**Automated Changelog Generation**:
|
|
1147
|
+
- Use conventional commits
|
|
1148
|
+
- Generate changelog from commit messages
|
|
1149
|
+
- Include breaking changes section
|
|
1150
|
+
- Link to issues and merge requests
|
|
1151
|
+
|
|
1152
|
+
**Changelog Format**:
|
|
1153
|
+
```markdown
|
|
1154
|
+
# Changelog
|
|
1155
|
+
|
|
1156
|
+
## [2.0.0] - 2024-01-15
|
|
1157
|
+
|
|
1158
|
+
### Breaking Changes
|
|
1159
|
+
- Changed CLI flag `--output` to `--format`
|
|
1160
|
+
|
|
1161
|
+
### Features
|
|
1162
|
+
- Added automatic CDK synthesis
|
|
1163
|
+
- Added cost threshold enforcement
|
|
1164
|
+
- Added 5 new resource calculators
|
|
1165
|
+
|
|
1166
|
+
### Bug Fixes
|
|
1167
|
+
- Fixed multi-stack cost aggregation
|
|
1168
|
+
- Fixed cache invalidation logic
|
|
1169
|
+
|
|
1170
|
+
### Documentation
|
|
1171
|
+
- Added GitLab CI integration guide
|
|
1172
|
+
- Updated configuration reference
|
|
1173
|
+
```
|
|
1174
|
+
|
|
1175
|
+
### Support for Multiple Package Managers
|
|
1176
|
+
|
|
1177
|
+
**NPM**:
|
|
1178
|
+
```bash
|
|
1179
|
+
npm install cdk-cost-analyzer
|
|
1180
|
+
```
|
|
1181
|
+
|
|
1182
|
+
**Yarn**:
|
|
1183
|
+
```bash
|
|
1184
|
+
yarn add cdk-cost-analyzer
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
**PNPM**:
|
|
1188
|
+
```bash
|
|
1189
|
+
pnpm add cdk-cost-analyzer
|
|
1190
|
+
```
|
|
1191
|
+
|
|
1192
|
+
All package managers supported through standard package.json.
|
|
1193
|
+
|
|
1194
|
+
## Documentation Requirements
|
|
1195
|
+
|
|
1196
|
+
### New Documentation Needed
|
|
1197
|
+
|
|
1198
|
+
1. **Configuration File Reference**: Complete schema documentation
|
|
1199
|
+
2. **GitLab CI Integration Guide**: Step-by-step setup instructions
|
|
1200
|
+
3. **Threshold Configuration Guide**: How to set appropriate thresholds
|
|
1201
|
+
4. **Troubleshooting Guide**: Common errors and solutions
|
|
1202
|
+
5. **Resource Calculator Reference**: Assumptions for each resource type
|
|
1203
|
+
6. **Migration Guide**: Upgrading from Phase 1/2
|
|
1204
|
+
7. **Release Process Guide**: How to publish new versions
|
|
1205
|
+
8. **Contributing Guide**: Development setup and contribution workflow
|
|
1206
|
+
|
|
1207
|
+
### Updated Documentation
|
|
1208
|
+
|
|
1209
|
+
1. **README**: Add configuration and pipeline examples
|
|
1210
|
+
2. **CLI Reference**: Document new flags and commands
|
|
1211
|
+
3. **API Reference**: Document new interfaces and options
|
|
1212
|
+
4. **Installation Guide**: Multiple installation methods
|
|
1213
|
+
5. **Changelog**: Automated generation from commits
|