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.
Files changed (228) hide show
  1. package/.cdk-cost-analyzer-cache/metadata.json +12 -0
  2. package/.gitlab-ci.yml +214 -0
  3. package/.husky/pre-commit +12 -0
  4. package/.kiro/hooks/accessibility-audit.kiro.hook +18 -0
  5. package/.kiro/hooks/api-schema-validation.kiro.hook +21 -0
  6. package/.kiro/hooks/auto-test-on-save.kiro.hook +19 -0
  7. package/.kiro/hooks/cdk-synth-on-change.kiro.hook +20 -0
  8. package/.kiro/hooks/code-coverage-check.kiro.hook +14 -0
  9. package/.kiro/hooks/commit-message-helper.kiro.hook +14 -0
  10. package/.kiro/hooks/dependency-update-check.kiro.hook +14 -0
  11. package/.kiro/hooks/env-file-validation.kiro.hook +18 -0
  12. package/.kiro/hooks/lint-and-format-on-save.kiro.hook +21 -0
  13. package/.kiro/hooks/mcp-config-validation.kiro.hook +17 -0
  14. package/.kiro/hooks/mcp-server-test.kiro.hook +14 -0
  15. package/.kiro/hooks/performance-analysis.kiro.hook +14 -0
  16. package/.kiro/hooks/readme-spell-check.kiro.hook +14 -0
  17. package/.kiro/hooks/security-scan-on-dependency-change.kiro.hook +21 -0
  18. package/.kiro/hooks/translation-update.kiro.hook +18 -0
  19. package/.kiro/hooks/update-documentation.kiro.hook +18 -0
  20. package/.kiro/settings/mcp.json +20 -0
  21. package/.kiro/specs/cdk-cost-analyzer/design.md +620 -0
  22. package/.kiro/specs/cdk-cost-analyzer/requirements.md +183 -0
  23. package/.kiro/specs/cdk-cost-analyzer/tasks.md +357 -0
  24. package/.kiro/specs/github-actions-ci/design.md +281 -0
  25. package/.kiro/specs/github-actions-ci/requirements.md +86 -0
  26. package/.kiro/specs/github-actions-ci/tasks.md +115 -0
  27. package/.kiro/specs/nlb-calculator-test-coverage/design.md +190 -0
  28. package/.kiro/specs/nlb-calculator-test-coverage/requirements.md +84 -0
  29. package/.kiro/specs/nlb-calculator-test-coverage/tasks.md +150 -0
  30. package/.kiro/specs/production-readiness/design.md +1213 -0
  31. package/.kiro/specs/production-readiness/requirements.md +312 -0
  32. package/.kiro/specs/production-readiness/tasks.md +269 -0
  33. package/.kiro/specs/repository-cleanup/design.md +283 -0
  34. package/.kiro/specs/repository-cleanup/requirements.md +74 -0
  35. package/.kiro/specs/repository-cleanup/tasks.md +64 -0
  36. package/.kiro/steering/aws-cli-best-practices.md +41 -0
  37. package/.kiro/steering/cdk-best-practices.md +49 -0
  38. package/.kiro/steering/development-standards.md +54 -0
  39. package/.kiro/steering/docker-best-practices.md +34 -0
  40. package/.kiro/steering/documentation-style.md +151 -0
  41. package/.kiro/steering/git-best-practices.md +37 -0
  42. package/.kiro/steering/mcp-best-practices.md +95 -0
  43. package/.kiro/steering/python-best-practices.md +48 -0
  44. package/.kiro/steering/react-best-practices.md +44 -0
  45. package/.kiro/steering/security-best-practices.md +41 -0
  46. package/.kiro/steering/testing-best-practices.md +59 -0
  47. package/.kiro/steering/typescript-best-practices.md +40 -0
  48. package/CHANGELOG.md +49 -0
  49. package/CONTRIBUTING.md +258 -0
  50. package/LICENSE +19 -0
  51. package/README.md +480 -0
  52. package/SECURITY.md +117 -0
  53. package/dist/api/index.d.ts +11 -0
  54. package/dist/api/index.js +65 -0
  55. package/dist/api/types.d.ts +15 -0
  56. package/dist/api/types.js +3 -0
  57. package/dist/cli/index.d.ts +2 -0
  58. package/dist/cli/index.js +262 -0
  59. package/dist/config/ConfigManager.d.ts +40 -0
  60. package/dist/config/ConfigManager.js +238 -0
  61. package/dist/config/index.d.ts +2 -0
  62. package/dist/config/index.js +19 -0
  63. package/dist/config/types.d.ts +72 -0
  64. package/dist/config/types.js +15 -0
  65. package/dist/diff/DiffEngine.d.ts +7 -0
  66. package/dist/diff/DiffEngine.js +73 -0
  67. package/dist/diff/index.d.ts +2 -0
  68. package/dist/diff/index.js +21 -0
  69. package/dist/diff/types.d.ts +20 -0
  70. package/dist/diff/types.js +3 -0
  71. package/dist/integrations/GitLabIntegration.d.ts +7 -0
  72. package/dist/integrations/GitLabIntegration.js +45 -0
  73. package/dist/integrations/index.d.ts +2 -0
  74. package/dist/integrations/index.js +21 -0
  75. package/dist/integrations/types.d.ts +11 -0
  76. package/dist/integrations/types.js +13 -0
  77. package/dist/parser/TemplateParser.d.ts +8 -0
  78. package/dist/parser/TemplateParser.js +75 -0
  79. package/dist/parser/index.d.ts +2 -0
  80. package/dist/parser/index.js +22 -0
  81. package/dist/parser/types.d.ts +30 -0
  82. package/dist/parser/types.js +3 -0
  83. package/dist/pipeline/PipelineOrchestrator.d.ts +23 -0
  84. package/dist/pipeline/PipelineOrchestrator.js +191 -0
  85. package/dist/pipeline/index.d.ts +2 -0
  86. package/dist/pipeline/index.js +19 -0
  87. package/dist/pipeline/types.d.ts +41 -0
  88. package/dist/pipeline/types.js +13 -0
  89. package/dist/pricing/CacheManager.d.ts +75 -0
  90. package/dist/pricing/CacheManager.js +195 -0
  91. package/dist/pricing/PricingClient.d.ts +17 -0
  92. package/dist/pricing/PricingClient.js +122 -0
  93. package/dist/pricing/PricingService.d.ts +16 -0
  94. package/dist/pricing/PricingService.js +149 -0
  95. package/dist/pricing/calculators/ALBCalculator.d.ts +16 -0
  96. package/dist/pricing/calculators/ALBCalculator.js +163 -0
  97. package/dist/pricing/calculators/APIGatewayCalculator.d.ts +10 -0
  98. package/dist/pricing/calculators/APIGatewayCalculator.js +177 -0
  99. package/dist/pricing/calculators/CloudFrontCalculator.d.ts +59 -0
  100. package/dist/pricing/calculators/CloudFrontCalculator.js +151 -0
  101. package/dist/pricing/calculators/DynamoDBCalculator.d.ts +9 -0
  102. package/dist/pricing/calculators/DynamoDBCalculator.js +146 -0
  103. package/dist/pricing/calculators/EC2Calculator.d.ts +7 -0
  104. package/dist/pricing/calculators/EC2Calculator.js +80 -0
  105. package/dist/pricing/calculators/ECSCalculator.d.ts +9 -0
  106. package/dist/pricing/calculators/ECSCalculator.js +116 -0
  107. package/dist/pricing/calculators/ElastiCacheCalculator.d.ts +8 -0
  108. package/dist/pricing/calculators/ElastiCacheCalculator.js +106 -0
  109. package/dist/pricing/calculators/LambdaCalculator.d.ts +13 -0
  110. package/dist/pricing/calculators/LambdaCalculator.js +111 -0
  111. package/dist/pricing/calculators/NLBCalculator.d.ts +16 -0
  112. package/dist/pricing/calculators/NLBCalculator.js +138 -0
  113. package/dist/pricing/calculators/NatGatewayCalculator.d.ts +12 -0
  114. package/dist/pricing/calculators/NatGatewayCalculator.js +116 -0
  115. package/dist/pricing/calculators/RDSCalculator.d.ts +9 -0
  116. package/dist/pricing/calculators/RDSCalculator.js +103 -0
  117. package/dist/pricing/calculators/S3Calculator.d.ts +8 -0
  118. package/dist/pricing/calculators/S3Calculator.js +68 -0
  119. package/dist/pricing/calculators/VPCEndpointCalculator.d.ts +12 -0
  120. package/dist/pricing/calculators/VPCEndpointCalculator.js +129 -0
  121. package/dist/pricing/index.d.ts +10 -0
  122. package/dist/pricing/index.js +37 -0
  123. package/dist/pricing/types.d.ts +53 -0
  124. package/dist/pricing/types.js +22 -0
  125. package/dist/releasetag.txt +1 -0
  126. package/dist/reporter/Reporter.d.ts +18 -0
  127. package/dist/reporter/Reporter.js +412 -0
  128. package/dist/reporter/index.d.ts +2 -0
  129. package/dist/reporter/index.js +21 -0
  130. package/dist/reporter/types.d.ts +72 -0
  131. package/dist/reporter/types.js +3 -0
  132. package/dist/synthesis/SynthesisOrchestrator.d.ts +26 -0
  133. package/dist/synthesis/SynthesisOrchestrator.js +243 -0
  134. package/dist/synthesis/index.d.ts +2 -0
  135. package/dist/synthesis/index.js +19 -0
  136. package/dist/synthesis/types.d.ts +17 -0
  137. package/dist/synthesis/types.js +13 -0
  138. package/dist/threshold/ThresholdEnforcer.d.ts +29 -0
  139. package/dist/threshold/ThresholdEnforcer.js +143 -0
  140. package/dist/threshold/index.d.ts +2 -0
  141. package/dist/threshold/index.js +19 -0
  142. package/dist/threshold/types.d.ts +15 -0
  143. package/dist/threshold/types.js +17 -0
  144. package/docs/CALCULATORS.md +820 -0
  145. package/docs/CI_CD.md +608 -0
  146. package/docs/CONFIGURATION.md +407 -0
  147. package/docs/DEVELOPMENT.md +387 -0
  148. package/docs/RELEASE.md +223 -0
  149. package/docs/TROUBLESHOOTING.md +847 -0
  150. package/examples/.cdk-cost-analyzer.yml +85 -0
  151. package/examples/.gitlab-ci.yml +125 -0
  152. package/examples/api-usage.js +26 -0
  153. package/examples/complex/base.json +16 -0
  154. package/examples/complex/target.json +29 -0
  155. package/examples/monorepo/.gitlab-ci.yml +251 -0
  156. package/examples/monorepo/README.md +341 -0
  157. package/examples/monorepo/package.json +27 -0
  158. package/examples/monorepo/packages/backend-infra/.cdk-cost-analyzer.yml +34 -0
  159. package/examples/monorepo/packages/backend-infra/bin/app.ts +16 -0
  160. package/examples/monorepo/packages/backend-infra/cdk.json +7 -0
  161. package/examples/monorepo/packages/backend-infra/lib/backend-stack.ts +128 -0
  162. package/examples/monorepo/packages/backend-infra/package.json +30 -0
  163. package/examples/monorepo/packages/backend-infra/tsconfig.json +11 -0
  164. package/examples/monorepo/packages/data-infra/.cdk-cost-analyzer.yml +38 -0
  165. package/examples/monorepo/packages/data-infra/bin/app.ts +16 -0
  166. package/examples/monorepo/packages/data-infra/cdk.json +7 -0
  167. package/examples/monorepo/packages/data-infra/lib/data-stack.ts +121 -0
  168. package/examples/monorepo/packages/data-infra/package.json +30 -0
  169. package/examples/monorepo/packages/data-infra/tsconfig.json +11 -0
  170. package/examples/monorepo/packages/frontend-infra/.cdk-cost-analyzer.yml +31 -0
  171. package/examples/monorepo/packages/frontend-infra/bin/app.ts +16 -0
  172. package/examples/monorepo/packages/frontend-infra/cdk.json +7 -0
  173. package/examples/monorepo/packages/frontend-infra/lib/frontend-stack.ts +60 -0
  174. package/examples/monorepo/packages/frontend-infra/package.json +30 -0
  175. package/examples/monorepo/packages/frontend-infra/tsconfig.json +11 -0
  176. package/examples/monorepo/tsconfig.json +35 -0
  177. package/examples/multi-stack/.cdk-cost-analyzer.yml +72 -0
  178. package/examples/multi-stack/.gitlab-ci.yml +184 -0
  179. package/examples/multi-stack/README.md +279 -0
  180. package/examples/multi-stack/bin/app.ts +36 -0
  181. package/examples/multi-stack/cdk.json +72 -0
  182. package/examples/multi-stack/lib/compute-stack.ts +128 -0
  183. package/examples/multi-stack/lib/networking-stack.ts +69 -0
  184. package/examples/multi-stack/lib/storage-stack.ts +141 -0
  185. package/examples/multi-stack/package-lock.json +4437 -0
  186. package/examples/multi-stack/package.json +42 -0
  187. package/examples/multi-stack/tsconfig.json +34 -0
  188. package/examples/simple/base.json +8 -0
  189. package/examples/simple/target.json +14 -0
  190. package/examples/single-stack/.NVP +0 -0
  191. package/examples/single-stack/.cdk-cost-analyzer.yml +52 -0
  192. package/examples/single-stack/.gitlab-ci.yml +126 -0
  193. package/examples/single-stack/README.md +184 -0
  194. package/examples/single-stack/UeK +0 -0
  195. package/examples/single-stack/bin/app.ts +16 -0
  196. package/examples/single-stack/cdk.json +72 -0
  197. package/examples/single-stack/lib/infrastructure-stack.ts +119 -0
  198. package/examples/single-stack/package-lock.json +4443 -0
  199. package/examples/single-stack/package.json +38 -0
  200. package/examples/single-stack/tsconfig.json +34 -0
  201. package/package.json +139 -0
  202. package/test-cdk-project/README-COMPUTE.md +141 -0
  203. package/test-cdk-project/README.md +95 -0
  204. package/test-cdk-project/app-with-compute.js +102 -0
  205. package/test-cdk-project/app.js +81 -0
  206. package/test-cdk-project/cdk-compute.json +3 -0
  207. package/test-cdk-project/cdk.context.json +7 -0
  208. package/test-cdk-project/cdk.json +3 -0
  209. package/test-cdk-project/cdk.out/TestStack.assets.json +21 -0
  210. package/test-cdk-project/cdk.out/TestStack.template.json +115 -0
  211. package/test-cdk-project/cdk.out/cdk.out +1 -0
  212. package/test-cdk-project/cdk.out/manifest.json +503 -0
  213. package/test-cdk-project/cdk.out/tree.json +1 -0
  214. package/test-cdk-project/cdk.out.base/TestStack.assets.json +21 -0
  215. package/test-cdk-project/cdk.out.base/TestStack.template.json +115 -0
  216. package/test-cdk-project/cdk.out.base/cdk.out +1 -0
  217. package/test-cdk-project/cdk.out.base/manifest.json +503 -0
  218. package/test-cdk-project/cdk.out.base/tree.json +1 -0
  219. package/test-cdk-project/cdk.out.target/TestStack.assets.json +21 -0
  220. package/test-cdk-project/cdk.out.target/TestStack.template.json +183 -0
  221. package/test-cdk-project/cdk.out.target/cdk.out +1 -0
  222. package/test-cdk-project/cdk.out.target/manifest.json +521 -0
  223. package/test-cdk-project/cdk.out.target/tree.json +1 -0
  224. package/test-cdk-project/package-lock.json +422 -0
  225. package/test-cdk-project/package.json +17 -0
  226. package/tools/workflows/README.md +102 -0
  227. package/tools/workflows/validate-workflows.js +109 -0
  228. package/tools/workflows/workflow-utils.ts +181 -0
@@ -0,0 +1,820 @@
1
+ # Resource Calculator Reference
2
+
3
+ This document provides detailed information about all supported AWS resource types, their cost calculation methods, default usage assumptions, and how to customize them.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Compute Resources](#compute-resources)
9
+ - [Storage Resources](#storage-resources)
10
+ - [Database Resources](#database-resources)
11
+ - [Networking Resources](#networking-resources)
12
+ - [Content Delivery Resources](#content-delivery-resources)
13
+ - [Serverless Resources](#serverless-resources)
14
+ - [Container Resources](#container-resources)
15
+ - [Customizing Assumptions](#customizing-assumptions)
16
+
17
+ ## Overview
18
+
19
+ CDK Cost Analyzer calculates monthly costs for AWS resources by querying the AWS Pricing API. For usage-based resources, default assumptions are applied to estimate costs. These assumptions can be customized via configuration files.
20
+
21
+ ### Cost Components
22
+
23
+ Each resource calculator returns:
24
+
25
+ - **Amount**: Estimated monthly cost in USD
26
+ - **Currency**: Always USD
27
+ - **Confidence**: Level of confidence in the estimate
28
+ - `high`: Exact pricing with minimal assumptions
29
+ - `medium`: Usage-based pricing with reasonable assumptions
30
+ - `low`: Significant assumptions or missing data
31
+ - `unknown`: Pricing data not available
32
+ - **Assumptions**: List of assumptions used in calculation
33
+
34
+ ### Confidence Levels
35
+
36
+ **High Confidence:**
37
+ - Fixed hourly rates (EC2, RDS instances)
38
+ - Known configuration (instance type, storage size)
39
+ - Minimal usage assumptions
40
+
41
+ **Medium Confidence:**
42
+ - Usage-based pricing with default assumptions
43
+ - Reasonable estimates based on typical usage
44
+ - Most resources fall into this category
45
+
46
+ **Low Confidence:**
47
+ - Multiple significant assumptions
48
+ - Highly variable usage patterns
49
+ - Limited pricing data
50
+
51
+ **Unknown:**
52
+ - Pricing data not available in region
53
+ - Unsupported resource type
54
+ - API errors
55
+
56
+ ## Compute Resources
57
+
58
+ ### AWS::EC2::Instance
59
+
60
+ **Description:** Amazon EC2 virtual servers
61
+
62
+ **Cost Components:**
63
+ - Instance hourly rate × 730 hours/month
64
+ - EBS storage (if attached)
65
+
66
+ **Default Assumptions:**
67
+ - 730 hours/month (full month, always running)
68
+ - On-demand pricing (no Reserved Instances or Savings Plans)
69
+ - Linux operating system
70
+ - No additional EBS volumes beyond root
71
+
72
+ **Configuration:**
73
+ ```yaml
74
+ usageAssumptions:
75
+ ec2:
76
+ hoursPerMonth: 730 # Full month
77
+ ```
78
+
79
+ **Example:**
80
+ ```
81
+ Instance Type: t3.medium
82
+ Region: eu-central-1
83
+ Hourly Rate: $0.0416
84
+ Monthly Cost: $0.0416 × 730 = $30.37
85
+ ```
86
+
87
+ **Notes:**
88
+ - Actual instance type read from template properties
89
+ - Different pricing for Windows, RHEL, SUSE
90
+ - Spot instances not supported
91
+ - Reserved Instance discounts not applied
92
+
93
+ ## Storage Resources
94
+
95
+ ### AWS::S3::Bucket
96
+
97
+ **Description:** Amazon S3 object storage
98
+
99
+ **Cost Components:**
100
+ - Storage: GB-month for standard storage
101
+ - Requests: GET, PUT, POST, LIST operations
102
+ - Data transfer: Out to internet (not calculated)
103
+
104
+ **Default Assumptions:**
105
+ - 100 GB standard storage
106
+ - 10,000 GET requests per month
107
+ - 1,000 PUT requests per month
108
+ - No data transfer costs
109
+
110
+ **Configuration:**
111
+ ```yaml
112
+ usageAssumptions:
113
+ s3:
114
+ storageGB: 100
115
+ getRequests: 10000
116
+ putRequests: 1000
117
+ ```
118
+
119
+ **Example:**
120
+ ```
121
+ Storage: 100 GB × $0.023/GB = $2.30
122
+ GET requests: 10,000 × $0.0004/1000 = $0.004
123
+ PUT requests: 1,000 × $0.005/1000 = $0.005
124
+ Total: $2.31/month
125
+ ```
126
+
127
+ **Notes:**
128
+ - Only standard storage class supported
129
+ - Intelligent-Tiering, Glacier not calculated
130
+ - Cross-region replication costs not included
131
+ - Lifecycle policies not considered
132
+
133
+ ## Database Resources
134
+
135
+ ### AWS::RDS::DBInstance
136
+
137
+ **Description:** Amazon RDS managed relational databases
138
+
139
+ **Cost Components:**
140
+ - Instance hourly rate × 730 hours/month
141
+ - Storage: GB-month for allocated storage
142
+ - Backup storage (not calculated)
143
+ - I/O operations (not calculated)
144
+
145
+ **Default Assumptions:**
146
+ - 730 hours/month (always running)
147
+ - Single-AZ deployment
148
+ - 100 GB General Purpose (gp2) storage
149
+ - No backup storage costs
150
+ - No I/O costs
151
+
152
+ **Configuration:**
153
+ ```yaml
154
+ usageAssumptions:
155
+ rds:
156
+ hoursPerMonth: 730
157
+ storageGB: 100
158
+ ```
159
+
160
+ **Example:**
161
+ ```
162
+ Instance: db.t3.medium
163
+ Hourly Rate: $0.068
164
+ Storage: 100 GB × $0.115/GB
165
+ Monthly Cost: ($0.068 × 730) + (100 × $0.115) = $61.14
166
+ ```
167
+
168
+ **Notes:**
169
+ - Actual instance class and storage read from template
170
+ - Multi-AZ doubles instance cost
171
+ - Aurora pricing different from standard RDS
172
+ - Read replicas counted as separate instances
173
+
174
+ ### AWS::DynamoDB::Table
175
+
176
+ **Description:** Amazon DynamoDB NoSQL database
177
+
178
+ **Cost Components:**
179
+
180
+ **Provisioned Mode:**
181
+ - Read Capacity Units (RCU) × hours × rate
182
+ - Write Capacity Units (WCU) × hours × rate
183
+ - Storage: GB-month
184
+
185
+ **On-Demand Mode:**
186
+ - Read Request Units × rate
187
+ - Write Request Units × rate
188
+ - Storage: GB-month
189
+
190
+ **Default Assumptions (Provisioned):**
191
+ - 5 RCU
192
+ - 5 WCU
193
+ - 10 GB storage
194
+
195
+ **Default Assumptions (On-Demand):**
196
+ - 10 million read requests/month
197
+ - 1 million write requests/month
198
+ - 10 GB storage
199
+
200
+ **Configuration:**
201
+ ```yaml
202
+ usageAssumptions:
203
+ dynamodb:
204
+ provisioned:
205
+ readCapacityUnits: 5
206
+ writeCapacityUnits: 5
207
+ storageGB: 10
208
+ onDemand:
209
+ readRequests: 10000000
210
+ writeRequests: 1000000
211
+ storageGB: 10
212
+ ```
213
+
214
+ **Example (Provisioned):**
215
+ ```
216
+ RCU: 5 × 730 hours × $0.00013/hour = $0.47
217
+ WCU: 5 × 730 hours × $0.00065/hour = $2.37
218
+ Storage: 10 GB × $0.25/GB = $2.50
219
+ Total: $5.34/month
220
+ ```
221
+
222
+ **Notes:**
223
+ - Billing mode read from template
224
+ - Global tables multiply costs by number of regions
225
+ - DynamoDB Streams not calculated
226
+ - Backup costs not included
227
+
228
+ ## Networking Resources
229
+
230
+ ### AWS::EC2::NatGateway
231
+
232
+ **Description:** NAT Gateway for private subnet internet access
233
+
234
+ **Cost Components:**
235
+ - Hourly rate × 730 hours/month
236
+ - Data processing: GB processed × rate
237
+
238
+ **Default Assumptions:**
239
+ - 730 hours/month (always running)
240
+ - 100 GB data processed per month
241
+
242
+ **Configuration:**
243
+ ```yaml
244
+ usageAssumptions:
245
+ natGateway:
246
+ dataProcessedGB: 100
247
+ ```
248
+
249
+ **Example:**
250
+ ```
251
+ Hourly Rate: $0.045
252
+ Data Processing: $0.045/GB
253
+ Monthly Cost: ($0.045 × 730) + (100 × $0.045) = $37.35
254
+ ```
255
+
256
+ **Notes:**
257
+ - Each NAT Gateway is per availability zone
258
+ - Data processing charged for all traffic
259
+ - No charge for data transfer within same AZ
260
+ - Consider NAT instances for cost savings
261
+
262
+ ### AWS::ElasticLoadBalancingV2::LoadBalancer (Application)
263
+
264
+ **Description:** Application Load Balancer for HTTP/HTTPS traffic
265
+
266
+ **Cost Components:**
267
+ - Hourly rate × 730 hours/month
268
+ - Load Balancer Capacity Units (LCU) × hours × rate
269
+
270
+ **LCU Dimensions:**
271
+ - New connections: 25/second per LCU
272
+ - Active connections: 3,000/minute per LCU
273
+ - Processed bytes: 1 GB/hour per LCU
274
+ - Rule evaluations: 1,000/second per LCU
275
+
276
+ **Default Assumptions:**
277
+ - 730 hours/month (always running)
278
+ - 25 new connections/second
279
+ - 3,000 active connections/minute
280
+ - 100 GB processed per month
281
+
282
+ **Configuration:**
283
+ ```yaml
284
+ usageAssumptions:
285
+ alb:
286
+ newConnectionsPerSecond: 25
287
+ activeConnectionsPerMinute: 3000
288
+ processedBytesGB: 100
289
+ ```
290
+
291
+ **Example:**
292
+ ```
293
+ Hourly Rate: $0.0225
294
+ LCU Rate: $0.008/hour
295
+ LCU Consumption: 1 LCU/hour (max of all dimensions)
296
+ Monthly Cost: ($0.0225 × 730) + ($0.008 × 1 × 730) = $22.27
297
+ ```
298
+
299
+ **Notes:**
300
+ - Billed for highest LCU dimension
301
+ - SSL/TLS certificates via ACM are free
302
+ - Cross-zone load balancing included
303
+ - WebSocket connections count as active connections
304
+
305
+ ### AWS::ElasticLoadBalancingV2::LoadBalancer (Network)
306
+
307
+ **Description:** Network Load Balancer for TCP/UDP traffic
308
+
309
+ **Cost Components:**
310
+ - Hourly rate × 730 hours/month
311
+ - Load Balancer Capacity Units (NLCU) × hours × rate
312
+
313
+ **NLCU Dimensions:**
314
+ - New connections: 800/second per NLCU
315
+ - Active connections: 100,000/minute per NLCU
316
+ - Processed bytes: 1 GB/hour per NLCU
317
+
318
+ **Default Assumptions:**
319
+ - 730 hours/month (always running)
320
+ - 100 new connections/second
321
+ - 10,000 active connections/minute
322
+ - 100 GB processed per month
323
+
324
+ **Configuration:**
325
+ ```yaml
326
+ usageAssumptions:
327
+ nlb:
328
+ newConnectionsPerSecond: 100
329
+ activeConnectionsPerMinute: 10000
330
+ processedBytesGB: 100
331
+ ```
332
+
333
+ **Example:**
334
+ ```
335
+ Hourly Rate: $0.0225
336
+ NLCU Rate: $0.006/hour
337
+ NLCU Consumption: 0.125 NLCU/hour
338
+ Monthly Cost: ($0.0225 × 730) + ($0.006 × 0.125 × 730) = $16.99
339
+ ```
340
+
341
+ **Notes:**
342
+ - Generally cheaper than ALB for high throughput
343
+ - No HTTP/HTTPS features (path routing, host headers)
344
+ - Preserves source IP address
345
+ - Lower latency than ALB
346
+
347
+ ### AWS::EC2::VPCEndpoint
348
+
349
+ **Description:** Private connectivity to AWS services
350
+
351
+ **Cost Components:**
352
+
353
+ **Interface Endpoints:**
354
+ - Hourly rate × 730 hours/month
355
+ - Data processing: GB processed × rate
356
+
357
+ **Gateway Endpoints:**
358
+ - No charge (S3 and DynamoDB only)
359
+
360
+ **Default Assumptions (Interface):**
361
+ - 730 hours/month (always running)
362
+ - 100 GB data processed per month
363
+
364
+ **Configuration:**
365
+ ```yaml
366
+ usageAssumptions:
367
+ vpcEndpoint:
368
+ dataProcessedGB: 100
369
+ ```
370
+
371
+ **Example (Interface):**
372
+ ```
373
+ Hourly Rate: $0.01
374
+ Data Processing: $0.01/GB
375
+ Monthly Cost: ($0.01 × 730) + (100 × $0.01) = $8.30
376
+ ```
377
+
378
+ **Example (Gateway):**
379
+ ```
380
+ Monthly Cost: $0.00 (no charge)
381
+ ```
382
+
383
+ **Notes:**
384
+ - Gateway endpoints only for S3 and DynamoDB
385
+ - Interface endpoints for most other services
386
+ - Each endpoint per AZ incurs separate charges
387
+ - Data transfer within same region not charged
388
+
389
+ ## Content Delivery Resources
390
+
391
+ ### AWS::CloudFront::Distribution
392
+
393
+ **Description:** Content delivery network for global distribution
394
+
395
+ **Cost Components:**
396
+ - Data transfer out to internet
397
+ - HTTP/HTTPS requests
398
+ - Invalidation requests (not calculated)
399
+ - Field-level encryption (not calculated)
400
+
401
+ **Default Assumptions:**
402
+ - 100 GB data transfer out per month
403
+ - 1 million HTTP/HTTPS requests per month
404
+ - US/Europe price class
405
+
406
+ **Configuration:**
407
+ ```yaml
408
+ usageAssumptions:
409
+ cloudFront:
410
+ dataTransferGB: 100
411
+ requests: 1000000
412
+ ```
413
+
414
+ **Example:**
415
+ ```
416
+ Data Transfer: 100 GB × $0.085/GB = $8.50
417
+ Requests: 1M × $0.0075/10K = $0.75
418
+ Total: $9.25/month
419
+ ```
420
+
421
+ **Notes:**
422
+ - Pricing varies by region (edge location)
423
+ - First 1 TB/month data transfer is $0.085/GB
424
+ - Price decreases with volume
425
+ - Origin shield costs not included
426
+ - Lambda@Edge costs not included
427
+
428
+ ### AWS::ElastiCache::CacheCluster
429
+
430
+ **Description:** In-memory caching service (Redis/Memcached)
431
+
432
+ **Cost Components:**
433
+ - Node hourly rate × node count × 730 hours/month
434
+ - Backup storage (Redis only, not calculated)
435
+ - Data transfer (not calculated)
436
+
437
+ **Default Assumptions:**
438
+ - 730 hours/month (always running)
439
+ - Single node
440
+ - No backup storage costs
441
+
442
+ **Configuration:**
443
+ ```yaml
444
+ usageAssumptions:
445
+ elasticache:
446
+ hoursPerMonth: 730
447
+ ```
448
+
449
+ **Example:**
450
+ ```
451
+ Node Type: cache.t3.micro
452
+ Hourly Rate: $0.017
453
+ Node Count: 2
454
+ Monthly Cost: $0.017 × 2 × 730 = $24.82
455
+ ```
456
+
457
+ **Notes:**
458
+ - Actual node type and count read from template
459
+ - Multi-AZ (Redis) adds replica costs
460
+ - Memcached does not support replication
461
+ - Backup storage only for Redis
462
+ - Reserved nodes not supported
463
+
464
+ ## Serverless Resources
465
+
466
+ ### AWS::Lambda::Function
467
+
468
+ **Description:** Serverless compute functions
469
+
470
+ **Cost Components:**
471
+ - Request charges: Per million requests
472
+ - Compute charges: GB-seconds of execution
473
+
474
+ **Default Assumptions:**
475
+ - 1 million invocations per month
476
+ - 1,000ms average execution time
477
+ - Memory allocation from template (default 128 MB)
478
+
479
+ **Configuration:**
480
+ ```yaml
481
+ usageAssumptions:
482
+ lambda:
483
+ invocationsPerMonth: 1000000
484
+ averageDurationMs: 1000
485
+ ```
486
+
487
+ **Example:**
488
+ ```
489
+ Memory: 512 MB
490
+ Requests: 1M × $0.20/1M = $0.20
491
+ GB-seconds: (512/1024) × 1 × 1M = 500,000 GB-seconds
492
+ Compute: 500,000 × $0.0000166667 = $8.33
493
+ Total: $8.53/month
494
+ ```
495
+
496
+ **Notes:**
497
+ - First 1M requests free per month
498
+ - First 400,000 GB-seconds free per month
499
+ - Actual memory read from template
500
+ - Provisioned concurrency not calculated
501
+ - Lambda@Edge pricing different
502
+
503
+ ### AWS::ApiGateway::RestApi
504
+
505
+ **Description:** REST API management service
506
+
507
+ **Cost Components:**
508
+ - API requests: Per million requests
509
+ - Data transfer out (not calculated)
510
+ - Caching (not calculated)
511
+
512
+ **Default Assumptions:**
513
+ - 10 million requests per month
514
+ - No caching
515
+ - No data transfer costs
516
+
517
+ **Configuration:**
518
+ ```yaml
519
+ usageAssumptions:
520
+ apiGateway:
521
+ requestsPerMonth: 10000000
522
+ ```
523
+
524
+ **Example:**
525
+ ```
526
+ Requests: 10M × $3.50/1M = $35.00
527
+ Total: $35.00/month
528
+ ```
529
+
530
+ **Notes:**
531
+ - First 1 million requests free (first 12 months)
532
+ - WebSocket API pricing different
533
+ - HTTP API cheaper than REST API
534
+ - Caching adds significant cost
535
+
536
+ ### AWS::ApiGatewayV2::Api
537
+
538
+ **Description:** HTTP and WebSocket APIs
539
+
540
+ **Cost Components:**
541
+
542
+ **HTTP API:**
543
+ - API requests: Per million requests
544
+
545
+ **WebSocket API:**
546
+ - Messages: Per million messages
547
+ - Connection minutes
548
+
549
+ **Default Assumptions (HTTP):**
550
+ - 10 million requests per month
551
+
552
+ **Default Assumptions (WebSocket):**
553
+ - 1 million messages per month
554
+ - 100,000 connection minutes per month
555
+
556
+ **Configuration:**
557
+ ```yaml
558
+ usageAssumptions:
559
+ apiGatewayV2:
560
+ http:
561
+ requestsPerMonth: 10000000
562
+ websocket:
563
+ messagesPerMonth: 1000000
564
+ connectionMinutes: 100000
565
+ ```
566
+
567
+ **Example (HTTP):**
568
+ ```
569
+ Requests: 10M × $1.00/1M = $10.00
570
+ Total: $10.00/month
571
+ ```
572
+
573
+ **Example (WebSocket):**
574
+ ```
575
+ Messages: 1M × $1.00/1M = $1.00
576
+ Connection Minutes: 100K × $0.25/1M = $0.025
577
+ Total: $1.03/month
578
+ ```
579
+
580
+ **Notes:**
581
+ - HTTP API ~70% cheaper than REST API
582
+ - First 1 million requests free (first 12 months)
583
+ - WebSocket connections billed per minute
584
+ - Message size up to 128 KB
585
+
586
+ ## Container Resources
587
+
588
+ ### AWS::ECS::Service
589
+
590
+ **Description:** Elastic Container Service for Docker containers
591
+
592
+ **Cost Components:**
593
+
594
+ **Fargate Launch Type:**
595
+ - vCPU hours × rate
596
+ - GB memory hours × rate
597
+
598
+ **EC2 Launch Type:**
599
+ - EC2 instance costs (see AWS::EC2::Instance)
600
+
601
+ **Default Assumptions (Fargate):**
602
+ - 0.25 vCPU per task
603
+ - 0.5 GB memory per task
604
+ - 1 task running 730 hours/month
605
+
606
+ **Configuration:**
607
+ ```yaml
608
+ usageAssumptions:
609
+ ecs:
610
+ fargate:
611
+ vCpu: 0.25
612
+ memoryGB: 0.5
613
+ hoursPerMonth: 730
614
+ ```
615
+
616
+ **Example (Fargate):**
617
+ ```
618
+ vCPU: 0.25 × 730 × $0.04048 = $7.39
619
+ Memory: 0.5 × 730 × $0.004445 = $1.62
620
+ Total: $9.01/month per task
621
+ ```
622
+
623
+ **Notes:**
624
+ - Actual vCPU and memory read from template
625
+ - Task count multiplies cost
626
+ - Fargate Spot ~70% cheaper
627
+ - EC2 launch type uses EC2 pricing
628
+ - Data transfer costs not included
629
+
630
+ ## Customizing Assumptions
631
+
632
+ ### Configuration File
633
+
634
+ Create `.cdk-cost-analyzer.yml` in your project:
635
+
636
+ ```yaml
637
+ usageAssumptions:
638
+ # Compute
639
+ ec2:
640
+ hoursPerMonth: 730
641
+
642
+ # Storage
643
+ s3:
644
+ storageGB: 500
645
+ getRequests: 100000
646
+ putRequests: 10000
647
+
648
+ # Database
649
+ rds:
650
+ hoursPerMonth: 730
651
+ storageGB: 200
652
+
653
+ dynamodb:
654
+ provisioned:
655
+ readCapacityUnits: 10
656
+ writeCapacityUnits: 10
657
+ storageGB: 50
658
+ onDemand:
659
+ readRequests: 50000000
660
+ writeRequests: 5000000
661
+ storageGB: 50
662
+
663
+ # Networking
664
+ natGateway:
665
+ dataProcessedGB: 500
666
+
667
+ alb:
668
+ newConnectionsPerSecond: 50
669
+ activeConnectionsPerMinute: 5000
670
+ processedBytesGB: 1000
671
+
672
+ nlb:
673
+ newConnectionsPerSecond: 200
674
+ activeConnectionsPerMinute: 20000
675
+ processedBytesGB: 1000
676
+
677
+ vpcEndpoint:
678
+ dataProcessedGB: 200
679
+
680
+ # Content Delivery
681
+ cloudFront:
682
+ dataTransferGB: 1000
683
+ requests: 10000000
684
+
685
+ elasticache:
686
+ hoursPerMonth: 730
687
+
688
+ # Serverless
689
+ lambda:
690
+ invocationsPerMonth: 5000000
691
+ averageDurationMs: 500
692
+
693
+ apiGateway:
694
+ requestsPerMonth: 20000000
695
+
696
+ apiGatewayV2:
697
+ http:
698
+ requestsPerMonth: 20000000
699
+ websocket:
700
+ messagesPerMonth: 5000000
701
+ connectionMinutes: 500000
702
+
703
+ # Containers
704
+ ecs:
705
+ fargate:
706
+ vCpu: 0.5
707
+ memoryGB: 1.0
708
+ hoursPerMonth: 730
709
+ ```
710
+
711
+ ### Programmatic Configuration
712
+
713
+ ```typescript
714
+ import { analyzeCosts } from 'cdk-cost-analyzer';
715
+
716
+ const result = await analyzeCosts({
717
+ baseTemplate: baseContent,
718
+ targetTemplate: targetContent,
719
+ region: 'eu-central-1',
720
+ usageAssumptions: {
721
+ s3: {
722
+ storageGB: 500,
723
+ getRequests: 100000,
724
+ },
725
+ lambda: {
726
+ invocationsPerMonth: 5000000,
727
+ averageDurationMs: 500,
728
+ },
729
+ },
730
+ });
731
+ ```
732
+
733
+ ### Environment-Specific Assumptions
734
+
735
+ Use different assumptions for different environments:
736
+
737
+ ```yaml
738
+ # .cdk-cost-analyzer.yml
739
+ usageAssumptions:
740
+ production:
741
+ s3:
742
+ storageGB: 1000
743
+ lambda:
744
+ invocationsPerMonth: 10000000
745
+
746
+ development:
747
+ s3:
748
+ storageGB: 100
749
+ lambda:
750
+ invocationsPerMonth: 1000000
751
+ ```
752
+
753
+ Then specify environment:
754
+
755
+ ```bash
756
+ cdk-cost-analyzer pipeline --environment production
757
+ ```
758
+
759
+ ## Best Practices
760
+
761
+ ### Setting Assumptions
762
+
763
+ 1. **Use Actual Metrics**: Base assumptions on CloudWatch metrics from existing resources
764
+ 2. **Be Conservative**: Overestimate usage to avoid surprises
765
+ 3. **Document Reasoning**: Add comments explaining your assumptions
766
+ 4. **Review Regularly**: Update assumptions as usage patterns change
767
+
768
+ ### Monitoring Accuracy
769
+
770
+ 1. **Compare Estimates to Actuals**: Review AWS Cost Explorer after deployment
771
+ 2. **Adjust Assumptions**: Update configuration based on actual costs
772
+ 3. **Track Trends**: Monitor how estimates compare over time
773
+
774
+ ### Cost Optimization
775
+
776
+ 1. **Identify High-Cost Resources**: Focus optimization on expensive resources
777
+ 2. **Consider Alternatives**: Evaluate different resource types or configurations
778
+ 3. **Use Reserved Capacity**: Consider Reserved Instances or Savings Plans for predictable workloads
779
+ 4. **Right-Size Resources**: Match resource size to actual usage
780
+
781
+ ## Unsupported Resources
782
+
783
+ Resources without cost calculators are marked as "unknown cost" in reports:
784
+
785
+ - AWS::IAM::Role (no cost)
786
+ - AWS::IAM::Policy (no cost)
787
+ - AWS::Logs::LogGroup (minimal cost)
788
+ - AWS::CloudWatch::Alarm (minimal cost)
789
+ - AWS::Events::Rule (minimal cost)
790
+ - Custom resources (varies)
791
+
792
+ To exclude these from reports:
793
+
794
+ ```yaml
795
+ exclusions:
796
+ resourceTypes:
797
+ - AWS::IAM::Role
798
+ - AWS::IAM::Policy
799
+ - AWS::Logs::LogGroup
800
+ ```
801
+
802
+ ## Regional Pricing Differences
803
+
804
+ Pricing varies significantly by region. Always specify the correct region:
805
+
806
+ ```bash
807
+ cdk-cost-analyzer base.json target.json --region eu-central-1
808
+ ```
809
+
810
+ **Example Regional Differences (t3.medium):**
811
+ - us-east-1: $0.0416/hour
812
+ - eu-central-1: $0.0464/hour
813
+ - ap-southeast-1: $0.0504/hour
814
+
815
+ ## Additional Resources
816
+
817
+ - [AWS Pricing Calculator](https://calculator.aws/) - Official AWS pricing tool
818
+ - [AWS Cost Explorer](https://aws.amazon.com/aws-cost-management/aws-cost-explorer/) - Analyze actual costs
819
+ - [AWS Pricing API](https://aws.amazon.com/pricing/) - Programmatic pricing access
820
+ - [Configuration Guide](./CONFIGURATION.md) - Detailed configuration options