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,407 @@
|
|
|
1
|
+
# Configuration Guide
|
|
2
|
+
|
|
3
|
+
The CDK Cost Analyzer supports project-specific configuration through a configuration file. This allows you to customize cost thresholds, usage assumptions, resource exclusions, and synthesis settings.
|
|
4
|
+
|
|
5
|
+
## Configuration File
|
|
6
|
+
|
|
7
|
+
The tool searches for configuration files in the following order:
|
|
8
|
+
|
|
9
|
+
1. Path specified via `--config` flag
|
|
10
|
+
2. `.cdk-cost-analyzer.yml` in current directory
|
|
11
|
+
3. `.cdk-cost-analyzer.yaml` in current directory
|
|
12
|
+
4. `.cdk-cost-analyzer.json` in current directory
|
|
13
|
+
|
|
14
|
+
### Complete Example
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
# .cdk-cost-analyzer.yml
|
|
18
|
+
|
|
19
|
+
# Cost thresholds for pipeline enforcement
|
|
20
|
+
thresholds:
|
|
21
|
+
# Default thresholds for all environments
|
|
22
|
+
default:
|
|
23
|
+
warning: 50 # USD per month - triggers warning but passes
|
|
24
|
+
error: 200 # USD per month - fails pipeline
|
|
25
|
+
|
|
26
|
+
# Environment-specific thresholds
|
|
27
|
+
environments:
|
|
28
|
+
production:
|
|
29
|
+
warning: 25 # Stricter thresholds for production
|
|
30
|
+
error: 100
|
|
31
|
+
development:
|
|
32
|
+
warning: 100 # More lenient for development
|
|
33
|
+
error: 500
|
|
34
|
+
|
|
35
|
+
# Custom usage assumptions for cost estimation
|
|
36
|
+
usageAssumptions:
|
|
37
|
+
s3:
|
|
38
|
+
storageGB: 500
|
|
39
|
+
getRequests: 100000
|
|
40
|
+
putRequests: 10000
|
|
41
|
+
|
|
42
|
+
lambda:
|
|
43
|
+
invocationsPerMonth: 5000000
|
|
44
|
+
averageDurationMs: 500
|
|
45
|
+
|
|
46
|
+
natGateway:
|
|
47
|
+
dataProcessedGB: 500 # Data processed through NAT Gateway per month
|
|
48
|
+
|
|
49
|
+
alb:
|
|
50
|
+
newConnectionsPerSecond: 50
|
|
51
|
+
activeConnectionsPerMinute: 5000
|
|
52
|
+
processedBytesGB: 1000
|
|
53
|
+
|
|
54
|
+
nlb:
|
|
55
|
+
newConnectionsPerSecond: 100
|
|
56
|
+
activeConnectionsPerMinute: 10000
|
|
57
|
+
processedBytesGB: 1000
|
|
58
|
+
|
|
59
|
+
vpcEndpoint:
|
|
60
|
+
dataProcessedGB: 100 # Data processed through interface endpoints
|
|
61
|
+
|
|
62
|
+
cloudFront:
|
|
63
|
+
dataTransferGB: 100 # Data transfer out to internet per month
|
|
64
|
+
requests: 1000000 # HTTP/HTTPS requests per month
|
|
65
|
+
|
|
66
|
+
apiGateway:
|
|
67
|
+
requestsPerMonth: 10000000
|
|
68
|
+
|
|
69
|
+
# CDK synthesis configuration
|
|
70
|
+
synthesis:
|
|
71
|
+
appPath: ./infrastructure
|
|
72
|
+
outputPath: ./cdk.out
|
|
73
|
+
customCommand: npx cdk synth # Optional: custom synthesis command
|
|
74
|
+
context:
|
|
75
|
+
environment: production
|
|
76
|
+
region: eu-central-1
|
|
77
|
+
|
|
78
|
+
# Resource types to exclude from cost analysis
|
|
79
|
+
exclusions:
|
|
80
|
+
resourceTypes:
|
|
81
|
+
- AWS::IAM::Role
|
|
82
|
+
- AWS::IAM::Policy
|
|
83
|
+
- AWS::Logs::LogGroup
|
|
84
|
+
|
|
85
|
+
# Pricing data cache configuration
|
|
86
|
+
cache:
|
|
87
|
+
enabled: true
|
|
88
|
+
durationHours: 24
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Configuration Options
|
|
92
|
+
|
|
93
|
+
### Thresholds
|
|
94
|
+
|
|
95
|
+
Cost thresholds control pipeline behavior based on cost deltas:
|
|
96
|
+
|
|
97
|
+
**Warning Threshold**: Cost increases above this value trigger a warning but allow the pipeline to pass. Use this to notify developers of significant cost increases.
|
|
98
|
+
|
|
99
|
+
**Error Threshold**: Cost increases above this value fail the pipeline. Use this to enforce approval gates for expensive changes.
|
|
100
|
+
|
|
101
|
+
**Environment-Specific Thresholds**: Define different thresholds for different environments (production, staging, development).
|
|
102
|
+
|
|
103
|
+
Example:
|
|
104
|
+
|
|
105
|
+
```yaml
|
|
106
|
+
thresholds:
|
|
107
|
+
default:
|
|
108
|
+
warning: 50
|
|
109
|
+
error: 200
|
|
110
|
+
environments:
|
|
111
|
+
production:
|
|
112
|
+
warning: 25
|
|
113
|
+
error: 100
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Usage Assumptions
|
|
117
|
+
|
|
118
|
+
Customize default assumptions for usage-based pricing:
|
|
119
|
+
|
|
120
|
+
#### S3
|
|
121
|
+
```yaml
|
|
122
|
+
usageAssumptions:
|
|
123
|
+
s3:
|
|
124
|
+
storageGB: 500 # GB of standard storage
|
|
125
|
+
getRequests: 100000 # GET requests per month
|
|
126
|
+
putRequests: 10000 # PUT requests per month
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Lambda
|
|
130
|
+
```yaml
|
|
131
|
+
usageAssumptions:
|
|
132
|
+
lambda:
|
|
133
|
+
invocationsPerMonth: 5000000 # Function invocations per month
|
|
134
|
+
averageDurationMs: 500 # Average execution duration
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### NAT Gateway
|
|
138
|
+
```yaml
|
|
139
|
+
usageAssumptions:
|
|
140
|
+
natGateway:
|
|
141
|
+
dataProcessedGB: 500 # Data processed through NAT Gateway
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### Application Load Balancer
|
|
145
|
+
```yaml
|
|
146
|
+
usageAssumptions:
|
|
147
|
+
alb:
|
|
148
|
+
newConnectionsPerSecond: 50 # New connections per second
|
|
149
|
+
activeConnectionsPerMinute: 5000 # Active connections per minute
|
|
150
|
+
processedBytesGB: 1000 # GB processed per month
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Network Load Balancer
|
|
154
|
+
```yaml
|
|
155
|
+
usageAssumptions:
|
|
156
|
+
nlb:
|
|
157
|
+
newConnectionsPerSecond: 100 # New connections per second
|
|
158
|
+
activeConnectionsPerMinute: 10000 # Active connections per minute
|
|
159
|
+
processedBytesGB: 1000 # GB processed per month
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### VPC Endpoint
|
|
163
|
+
```yaml
|
|
164
|
+
usageAssumptions:
|
|
165
|
+
vpcEndpoint:
|
|
166
|
+
dataProcessedGB: 100 # Data processed through interface endpoints
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### CloudFront
|
|
170
|
+
```yaml
|
|
171
|
+
usageAssumptions:
|
|
172
|
+
cloudFront:
|
|
173
|
+
dataTransferGB: 100 # Data transfer out to internet per month
|
|
174
|
+
requests: 1000000 # HTTP/HTTPS requests per month
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### API Gateway
|
|
178
|
+
```yaml
|
|
179
|
+
usageAssumptions:
|
|
180
|
+
apiGateway:
|
|
181
|
+
requestsPerMonth: 10000000 # API requests per month
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Synthesis Configuration
|
|
185
|
+
|
|
186
|
+
Configure automatic CDK synthesis:
|
|
187
|
+
|
|
188
|
+
```yaml
|
|
189
|
+
synthesis:
|
|
190
|
+
appPath: ./infrastructure # Path to CDK application
|
|
191
|
+
outputPath: ./cdk.out # CDK output directory
|
|
192
|
+
customCommand: npx cdk synth # Custom synthesis command
|
|
193
|
+
context: # CDK context values
|
|
194
|
+
environment: production
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Timeout Behavior:**
|
|
198
|
+
- CDK synthesis has a built-in 25-second timeout to prevent hanging processes
|
|
199
|
+
- Process receives SIGTERM for graceful termination, followed by SIGKILL after 5 seconds
|
|
200
|
+
- If synthesis requires more time, use a custom command with extended timeout:
|
|
201
|
+
```yaml
|
|
202
|
+
synthesis:
|
|
203
|
+
customCommand: "timeout 60 npx cdk synth" # 60 second timeout
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Security Notes:**
|
|
207
|
+
- Commands are executed with `shell: false` to prevent injection attacks
|
|
208
|
+
- Arguments are passed as arrays rather than concatenated strings
|
|
209
|
+
region: eu-central-1
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Resource Exclusions
|
|
213
|
+
|
|
214
|
+
Exclude specific resource types from cost analysis:
|
|
215
|
+
|
|
216
|
+
```yaml
|
|
217
|
+
exclusions:
|
|
218
|
+
resourceTypes:
|
|
219
|
+
- AWS::IAM::Role
|
|
220
|
+
- AWS::IAM::Policy
|
|
221
|
+
- AWS::Logs::LogGroup
|
|
222
|
+
- AWS::CloudWatch::Alarm
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Common exclusions:
|
|
226
|
+
- **IAM Resources**: Roles, policies, users (no direct cost)
|
|
227
|
+
- **Log Groups**: Often minimal cost
|
|
228
|
+
- **CloudWatch Alarms**: Minimal cost
|
|
229
|
+
- **EventBridge Rules**: Minimal cost
|
|
230
|
+
|
|
231
|
+
### Cache Configuration
|
|
232
|
+
|
|
233
|
+
Configure pricing data caching:
|
|
234
|
+
|
|
235
|
+
```yaml
|
|
236
|
+
cache:
|
|
237
|
+
enabled: true # Enable caching
|
|
238
|
+
durationHours: 24 # Cache duration in hours
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Benefits of caching:
|
|
242
|
+
- Faster analysis (no API calls for cached data)
|
|
243
|
+
- Reduced AWS Pricing API usage
|
|
244
|
+
- Works offline with cached data
|
|
245
|
+
|
|
246
|
+
## Environment Detection
|
|
247
|
+
|
|
248
|
+
When using environment-specific thresholds, the tool detects the environment from:
|
|
249
|
+
|
|
250
|
+
1. `--environment` CLI flag
|
|
251
|
+
2. `CI_ENVIRONMENT_NAME` GitLab CI variable
|
|
252
|
+
3. Falls back to default thresholds
|
|
253
|
+
|
|
254
|
+
Example in GitLab CI:
|
|
255
|
+
|
|
256
|
+
```yaml
|
|
257
|
+
cost-analysis:production:
|
|
258
|
+
stage: cost-analysis
|
|
259
|
+
script:
|
|
260
|
+
- cdk-cost-analyzer pipeline --environment production
|
|
261
|
+
only:
|
|
262
|
+
- main
|
|
263
|
+
|
|
264
|
+
cost-analysis:development:
|
|
265
|
+
stage: cost-analysis
|
|
266
|
+
script:
|
|
267
|
+
- cdk-cost-analyzer pipeline --environment development
|
|
268
|
+
only:
|
|
269
|
+
- merge_requests
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Configuration Validation
|
|
273
|
+
|
|
274
|
+
The tool validates configuration on load:
|
|
275
|
+
|
|
276
|
+
**Errors** (fail immediately):
|
|
277
|
+
- Negative threshold values
|
|
278
|
+
- Negative usage assumption values
|
|
279
|
+
- Invalid cache duration
|
|
280
|
+
|
|
281
|
+
**Warnings** (displayed but continue):
|
|
282
|
+
- Warning threshold exceeds error threshold
|
|
283
|
+
- Missing environment thresholds (uses default)
|
|
284
|
+
|
|
285
|
+
Example validation error:
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
Error: Invalid configuration
|
|
289
|
+
Validation errors:
|
|
290
|
+
- thresholds.default.warning must be non-negative
|
|
291
|
+
- usageAssumptions.s3.storageGB must be non-negative
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## JSON Configuration
|
|
295
|
+
|
|
296
|
+
You can also use JSON format:
|
|
297
|
+
|
|
298
|
+
```json
|
|
299
|
+
{
|
|
300
|
+
"thresholds": {
|
|
301
|
+
"default": {
|
|
302
|
+
"warning": 50,
|
|
303
|
+
"error": 200
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
"usageAssumptions": {
|
|
307
|
+
"s3": {
|
|
308
|
+
"storageGB": 500
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
"cache": {
|
|
312
|
+
"enabled": true,
|
|
313
|
+
"durationHours": 24
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Best Practices
|
|
319
|
+
|
|
320
|
+
### Setting Thresholds
|
|
321
|
+
|
|
322
|
+
**Start Conservative**: Begin with low thresholds and adjust based on team needs.
|
|
323
|
+
|
|
324
|
+
**Per-Environment**: Use stricter thresholds for production, lenient for development.
|
|
325
|
+
|
|
326
|
+
**Team Alignment**: Set thresholds that match your FinOps policies and budget constraints.
|
|
327
|
+
|
|
328
|
+
### Usage Assumptions
|
|
329
|
+
|
|
330
|
+
**Based on Monitoring**: Use actual usage data from CloudWatch metrics.
|
|
331
|
+
|
|
332
|
+
**Conservative Estimates**: Err on the side of over-estimation to avoid surprises.
|
|
333
|
+
|
|
334
|
+
**Document Assumptions**: Add comments explaining your usage assumptions.
|
|
335
|
+
|
|
336
|
+
### Resource Exclusions
|
|
337
|
+
|
|
338
|
+
**Zero-Cost Resources**: Exclude IAM and other zero-cost resources.
|
|
339
|
+
|
|
340
|
+
**Minimal Cost Resources**: Consider excluding Log Groups if cost is negligible.
|
|
341
|
+
|
|
342
|
+
**Don't Over-Exclude**: Be cautious about excluding potentially expensive resources.
|
|
343
|
+
|
|
344
|
+
## Configuration Examples
|
|
345
|
+
|
|
346
|
+
### Small Team / Startup
|
|
347
|
+
|
|
348
|
+
```yaml
|
|
349
|
+
thresholds:
|
|
350
|
+
default:
|
|
351
|
+
warning: 100
|
|
352
|
+
error: 500
|
|
353
|
+
|
|
354
|
+
usageAssumptions:
|
|
355
|
+
s3:
|
|
356
|
+
storageGB: 50
|
|
357
|
+
lambda:
|
|
358
|
+
invocationsPerMonth: 1000000
|
|
359
|
+
|
|
360
|
+
exclusions:
|
|
361
|
+
resourceTypes:
|
|
362
|
+
- AWS::IAM::Role
|
|
363
|
+
- AWS::IAM::Policy
|
|
364
|
+
- AWS::Logs::LogGroup
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Enterprise / Production
|
|
368
|
+
|
|
369
|
+
```yaml
|
|
370
|
+
thresholds:
|
|
371
|
+
default:
|
|
372
|
+
warning: 25
|
|
373
|
+
error: 100
|
|
374
|
+
environments:
|
|
375
|
+
production:
|
|
376
|
+
warning: 10
|
|
377
|
+
error: 50
|
|
378
|
+
staging:
|
|
379
|
+
warning: 50
|
|
380
|
+
error: 200
|
|
381
|
+
development:
|
|
382
|
+
warning: 200
|
|
383
|
+
error: 1000
|
|
384
|
+
|
|
385
|
+
usageAssumptions:
|
|
386
|
+
s3:
|
|
387
|
+
storageGB: 1000
|
|
388
|
+
lambda:
|
|
389
|
+
invocationsPerMonth: 10000000
|
|
390
|
+
natGateway:
|
|
391
|
+
dataProcessedGB: 5000
|
|
392
|
+
alb:
|
|
393
|
+
newConnectionsPerSecond: 100
|
|
394
|
+
activeConnectionsPerMinute: 10000
|
|
395
|
+
processedBytesGB: 5000
|
|
396
|
+
|
|
397
|
+
cache:
|
|
398
|
+
enabled: true
|
|
399
|
+
durationHours: 12
|
|
400
|
+
|
|
401
|
+
exclusions:
|
|
402
|
+
resourceTypes:
|
|
403
|
+
- AWS::IAM::Role
|
|
404
|
+
- AWS::IAM::Policy
|
|
405
|
+
- AWS::Logs::LogGroup
|
|
406
|
+
- AWS::CloudWatch::Alarm
|
|
407
|
+
```
|