@build-astron-co/nimbus 0.2.0
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/LICENSE +21 -0
- package/README.md +628 -0
- package/bin/nimbus +38 -0
- package/package.json +80 -0
- package/src/__tests__/app.test.ts +76 -0
- package/src/__tests__/audit.test.ts +877 -0
- package/src/__tests__/circuit-breaker.test.ts +116 -0
- package/src/__tests__/cli-run.test.ts +115 -0
- package/src/__tests__/context-manager.test.ts +502 -0
- package/src/__tests__/context.test.ts +242 -0
- package/src/__tests__/enterprise.test.ts +401 -0
- package/src/__tests__/generator.test.ts +433 -0
- package/src/__tests__/hooks.test.ts +582 -0
- package/src/__tests__/init.test.ts +436 -0
- package/src/__tests__/intent-parser.test.ts +229 -0
- package/src/__tests__/llm-router.test.ts +209 -0
- package/src/__tests__/lsp.test.ts +293 -0
- package/src/__tests__/modes.test.ts +336 -0
- package/src/__tests__/permissions.test.ts +338 -0
- package/src/__tests__/serve.test.ts +275 -0
- package/src/__tests__/sessions.test.ts +227 -0
- package/src/__tests__/sharing.test.ts +288 -0
- package/src/__tests__/snapshots.test.ts +581 -0
- package/src/__tests__/state-db.test.ts +334 -0
- package/src/__tests__/stream-with-tools.test.ts +732 -0
- package/src/__tests__/subagents.test.ts +176 -0
- package/src/__tests__/system-prompt.test.ts +169 -0
- package/src/__tests__/tool-converter.test.ts +256 -0
- package/src/__tests__/tool-schemas.test.ts +397 -0
- package/src/__tests__/tools.test.ts +143 -0
- package/src/__tests__/version.test.ts +49 -0
- package/src/agent/compaction-agent.ts +227 -0
- package/src/agent/context-manager.ts +435 -0
- package/src/agent/context.ts +427 -0
- package/src/agent/deploy-preview.ts +426 -0
- package/src/agent/index.ts +68 -0
- package/src/agent/loop.ts +717 -0
- package/src/agent/modes.ts +429 -0
- package/src/agent/permissions.ts +466 -0
- package/src/agent/subagents/base.ts +116 -0
- package/src/agent/subagents/cost.ts +51 -0
- package/src/agent/subagents/explore.ts +42 -0
- package/src/agent/subagents/general.ts +54 -0
- package/src/agent/subagents/index.ts +102 -0
- package/src/agent/subagents/infra.ts +59 -0
- package/src/agent/subagents/security.ts +69 -0
- package/src/agent/system-prompt.ts +436 -0
- package/src/app.ts +122 -0
- package/src/audit/activity-log.ts +290 -0
- package/src/audit/compliance-checker.ts +540 -0
- package/src/audit/cost-tracker.ts +318 -0
- package/src/audit/index.ts +23 -0
- package/src/audit/security-scanner.ts +596 -0
- package/src/auth/guard.ts +75 -0
- package/src/auth/index.ts +56 -0
- package/src/auth/oauth.ts +455 -0
- package/src/auth/providers.ts +470 -0
- package/src/auth/sso.ts +113 -0
- package/src/auth/store.ts +505 -0
- package/src/auth/types.ts +187 -0
- package/src/build.ts +141 -0
- package/src/cli/index.ts +16 -0
- package/src/cli/init.ts +854 -0
- package/src/cli/openapi-spec.ts +356 -0
- package/src/cli/run.ts +237 -0
- package/src/cli/serve-auth.ts +80 -0
- package/src/cli/serve.ts +462 -0
- package/src/cli/web.ts +67 -0
- package/src/cli.ts +1417 -0
- package/src/clients/core-engine-client.ts +227 -0
- package/src/clients/enterprise-client.ts +334 -0
- package/src/clients/generator-client.ts +351 -0
- package/src/clients/git-client.ts +627 -0
- package/src/clients/github-client.ts +410 -0
- package/src/clients/helm-client.ts +504 -0
- package/src/clients/index.ts +80 -0
- package/src/clients/k8s-client.ts +497 -0
- package/src/clients/llm-client.ts +161 -0
- package/src/clients/rest-client.ts +130 -0
- package/src/clients/service-discovery.ts +33 -0
- package/src/clients/terraform-client.ts +482 -0
- package/src/clients/tools-client.ts +1843 -0
- package/src/clients/ws-client.ts +115 -0
- package/src/commands/analyze/index.ts +352 -0
- package/src/commands/apply/helm.ts +473 -0
- package/src/commands/apply/index.ts +213 -0
- package/src/commands/apply/k8s.ts +454 -0
- package/src/commands/apply/terraform.ts +582 -0
- package/src/commands/ask.ts +167 -0
- package/src/commands/audit/index.ts +238 -0
- package/src/commands/auth-cloud.ts +294 -0
- package/src/commands/auth-list.ts +134 -0
- package/src/commands/auth-profile.ts +121 -0
- package/src/commands/auth-status.ts +141 -0
- package/src/commands/aws/ec2.ts +501 -0
- package/src/commands/aws/iam.ts +397 -0
- package/src/commands/aws/index.ts +133 -0
- package/src/commands/aws/lambda.ts +396 -0
- package/src/commands/aws/rds.ts +439 -0
- package/src/commands/aws/s3.ts +439 -0
- package/src/commands/aws/vpc.ts +393 -0
- package/src/commands/aws-discover.ts +649 -0
- package/src/commands/aws-terraform.ts +805 -0
- package/src/commands/azure/aks.ts +376 -0
- package/src/commands/azure/functions.ts +253 -0
- package/src/commands/azure/index.ts +116 -0
- package/src/commands/azure/storage.ts +478 -0
- package/src/commands/azure/vm.ts +355 -0
- package/src/commands/billing/index.ts +256 -0
- package/src/commands/chat.ts +314 -0
- package/src/commands/config.ts +346 -0
- package/src/commands/cost/cloud-cost-estimator.ts +266 -0
- package/src/commands/cost/estimator.ts +79 -0
- package/src/commands/cost/index.ts +594 -0
- package/src/commands/cost/parsers/terraform.ts +273 -0
- package/src/commands/cost/parsers/types.ts +25 -0
- package/src/commands/cost/pricing/aws.ts +544 -0
- package/src/commands/cost/pricing/azure.ts +499 -0
- package/src/commands/cost/pricing/gcp.ts +396 -0
- package/src/commands/cost/pricing/index.ts +40 -0
- package/src/commands/demo.ts +250 -0
- package/src/commands/doctor.ts +794 -0
- package/src/commands/drift/index.ts +439 -0
- package/src/commands/explain.ts +277 -0
- package/src/commands/feedback.ts +389 -0
- package/src/commands/fix.ts +324 -0
- package/src/commands/fs/index.ts +402 -0
- package/src/commands/gcp/compute.ts +325 -0
- package/src/commands/gcp/functions.ts +271 -0
- package/src/commands/gcp/gke.ts +438 -0
- package/src/commands/gcp/iam.ts +344 -0
- package/src/commands/gcp/index.ts +129 -0
- package/src/commands/gcp/storage.ts +284 -0
- package/src/commands/generate-helm.ts +1249 -0
- package/src/commands/generate-k8s.ts +1560 -0
- package/src/commands/generate-terraform.ts +1460 -0
- package/src/commands/gh/index.ts +863 -0
- package/src/commands/git/index.ts +1343 -0
- package/src/commands/helm/index.ts +1126 -0
- package/src/commands/help.ts +539 -0
- package/src/commands/history.ts +142 -0
- package/src/commands/import.ts +868 -0
- package/src/commands/index.ts +367 -0
- package/src/commands/init.ts +1046 -0
- package/src/commands/k8s/index.ts +1137 -0
- package/src/commands/login.ts +631 -0
- package/src/commands/logout.ts +83 -0
- package/src/commands/onboarding.ts +228 -0
- package/src/commands/plan/display.ts +279 -0
- package/src/commands/plan/index.ts +599 -0
- package/src/commands/preview.ts +452 -0
- package/src/commands/questionnaire.ts +1270 -0
- package/src/commands/resume.ts +55 -0
- package/src/commands/team/index.ts +346 -0
- package/src/commands/template.ts +232 -0
- package/src/commands/tf/index.ts +1034 -0
- package/src/commands/upgrade.ts +550 -0
- package/src/commands/usage/index.ts +134 -0
- package/src/commands/version.ts +170 -0
- package/src/compat/index.ts +2 -0
- package/src/compat/runtime.ts +12 -0
- package/src/compat/sqlite.ts +107 -0
- package/src/config/index.ts +17 -0
- package/src/config/manager.ts +530 -0
- package/src/config/safety-policy.ts +358 -0
- package/src/config/schema.ts +125 -0
- package/src/config/types.ts +527 -0
- package/src/context/context-db.ts +199 -0
- package/src/demo/index.ts +349 -0
- package/src/demo/scenarios/full-journey.ts +229 -0
- package/src/demo/scenarios/getting-started.ts +127 -0
- package/src/demo/scenarios/helm-release.ts +341 -0
- package/src/demo/scenarios/k8s-deployment.ts +194 -0
- package/src/demo/scenarios/terraform-vpc.ts +170 -0
- package/src/demo/types.ts +92 -0
- package/src/engine/cost-estimator.ts +438 -0
- package/src/engine/diagram-generator.ts +256 -0
- package/src/engine/drift-detector.ts +902 -0
- package/src/engine/executor.ts +1035 -0
- package/src/engine/index.ts +76 -0
- package/src/engine/orchestrator.ts +636 -0
- package/src/engine/planner.ts +720 -0
- package/src/engine/safety.ts +743 -0
- package/src/engine/verifier.ts +770 -0
- package/src/enterprise/audit.ts +348 -0
- package/src/enterprise/auth.ts +270 -0
- package/src/enterprise/billing.ts +822 -0
- package/src/enterprise/index.ts +17 -0
- package/src/enterprise/teams.ts +443 -0
- package/src/generator/best-practices.ts +1608 -0
- package/src/generator/helm.ts +630 -0
- package/src/generator/index.ts +37 -0
- package/src/generator/intent-parser.ts +514 -0
- package/src/generator/kubernetes.ts +976 -0
- package/src/generator/terraform.ts +1867 -0
- package/src/history/index.ts +8 -0
- package/src/history/manager.ts +322 -0
- package/src/history/types.ts +34 -0
- package/src/hooks/config.ts +432 -0
- package/src/hooks/engine.ts +391 -0
- package/src/hooks/index.ts +4 -0
- package/src/llm/auth-bridge.ts +198 -0
- package/src/llm/circuit-breaker.ts +140 -0
- package/src/llm/config-loader.ts +201 -0
- package/src/llm/cost-calculator.ts +171 -0
- package/src/llm/index.ts +8 -0
- package/src/llm/model-aliases.ts +115 -0
- package/src/llm/provider-registry.ts +63 -0
- package/src/llm/providers/anthropic.ts +433 -0
- package/src/llm/providers/bedrock.ts +477 -0
- package/src/llm/providers/google.ts +405 -0
- package/src/llm/providers/ollama.ts +767 -0
- package/src/llm/providers/openai-compatible.ts +340 -0
- package/src/llm/providers/openai.ts +328 -0
- package/src/llm/providers/openrouter.ts +338 -0
- package/src/llm/router.ts +1035 -0
- package/src/llm/types.ts +232 -0
- package/src/lsp/client.ts +298 -0
- package/src/lsp/languages.ts +116 -0
- package/src/lsp/manager.ts +278 -0
- package/src/mcp/client.ts +402 -0
- package/src/mcp/index.ts +5 -0
- package/src/mcp/manager.ts +133 -0
- package/src/nimbus.ts +214 -0
- package/src/plugins/index.ts +27 -0
- package/src/plugins/loader.ts +334 -0
- package/src/plugins/manager.ts +376 -0
- package/src/plugins/types.ts +284 -0
- package/src/scanners/cicd-scanner.ts +258 -0
- package/src/scanners/cloud-scanner.ts +466 -0
- package/src/scanners/framework-scanner.ts +469 -0
- package/src/scanners/iac-scanner.ts +388 -0
- package/src/scanners/index.ts +539 -0
- package/src/scanners/language-scanner.ts +276 -0
- package/src/scanners/package-manager-scanner.ts +277 -0
- package/src/scanners/types.ts +172 -0
- package/src/sessions/manager.ts +365 -0
- package/src/sessions/types.ts +44 -0
- package/src/sharing/sync.ts +296 -0
- package/src/sharing/viewer.ts +97 -0
- package/src/snapshots/index.ts +2 -0
- package/src/snapshots/manager.ts +530 -0
- package/src/state/artifacts.ts +147 -0
- package/src/state/audit.ts +137 -0
- package/src/state/billing.ts +240 -0
- package/src/state/checkpoints.ts +117 -0
- package/src/state/config.ts +67 -0
- package/src/state/conversations.ts +14 -0
- package/src/state/credentials.ts +154 -0
- package/src/state/db.ts +58 -0
- package/src/state/index.ts +26 -0
- package/src/state/messages.ts +115 -0
- package/src/state/projects.ts +123 -0
- package/src/state/schema.ts +236 -0
- package/src/state/sessions.ts +147 -0
- package/src/state/teams.ts +200 -0
- package/src/telemetry.ts +108 -0
- package/src/tools/aws-ops.ts +952 -0
- package/src/tools/azure-ops.ts +579 -0
- package/src/tools/file-ops.ts +593 -0
- package/src/tools/gcp-ops.ts +625 -0
- package/src/tools/git-ops.ts +773 -0
- package/src/tools/github-ops.ts +799 -0
- package/src/tools/helm-ops.ts +943 -0
- package/src/tools/index.ts +17 -0
- package/src/tools/k8s-ops.ts +819 -0
- package/src/tools/schemas/converter.ts +184 -0
- package/src/tools/schemas/devops.ts +612 -0
- package/src/tools/schemas/index.ts +73 -0
- package/src/tools/schemas/standard.ts +1144 -0
- package/src/tools/schemas/types.ts +705 -0
- package/src/tools/terraform-ops.ts +862 -0
- package/src/types/ambient.d.ts +193 -0
- package/src/types/config.ts +83 -0
- package/src/types/drift.ts +116 -0
- package/src/types/enterprise.ts +335 -0
- package/src/types/index.ts +20 -0
- package/src/types/plan.ts +44 -0
- package/src/types/request.ts +65 -0
- package/src/types/response.ts +54 -0
- package/src/types/service.ts +51 -0
- package/src/ui/App.tsx +997 -0
- package/src/ui/DeployPreview.tsx +169 -0
- package/src/ui/Header.tsx +68 -0
- package/src/ui/InputBox.tsx +350 -0
- package/src/ui/MessageList.tsx +585 -0
- package/src/ui/PermissionPrompt.tsx +151 -0
- package/src/ui/StatusBar.tsx +158 -0
- package/src/ui/ToolCallDisplay.tsx +409 -0
- package/src/ui/chat-ui.ts +853 -0
- package/src/ui/index.ts +33 -0
- package/src/ui/ink/index.ts +711 -0
- package/src/ui/streaming.ts +176 -0
- package/src/ui/types.ts +57 -0
- package/src/utils/analytics.ts +72 -0
- package/src/utils/cost-warning.ts +27 -0
- package/src/utils/env.ts +46 -0
- package/src/utils/errors.ts +69 -0
- package/src/utils/event-bus.ts +38 -0
- package/src/utils/index.ts +24 -0
- package/src/utils/logger.ts +171 -0
- package/src/utils/rate-limiter.ts +121 -0
- package/src/utils/service-auth.ts +49 -0
- package/src/utils/validation.ts +53 -0
- package/src/version.ts +4 -0
- package/src/watcher/index.ts +163 -0
- package/src/wizard/approval.ts +383 -0
- package/src/wizard/index.ts +25 -0
- package/src/wizard/prompts.ts +338 -0
- package/src/wizard/types.ts +171 -0
- package/src/wizard/ui.ts +556 -0
- package/src/wizard/wizard.ts +304 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Azure Static Pricing Lookup
|
|
3
|
+
*
|
|
4
|
+
* Monthly on-demand pricing based on East US region as of 2024.
|
|
5
|
+
* These are approximate list prices used for quick estimation.
|
|
6
|
+
* Install Infracost for real-time, region-aware pricing.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { TerraformResource } from '../parsers/types';
|
|
10
|
+
import type { PricingResult } from './index';
|
|
11
|
+
|
|
12
|
+
const HOURS_PER_MONTH = 730;
|
|
13
|
+
|
|
14
|
+
// ------------------------------------------------------------------
|
|
15
|
+
// Virtual Machine pricing (on-demand, East US, Linux)
|
|
16
|
+
// ------------------------------------------------------------------
|
|
17
|
+
const VM_PRICING: Record<string, number> = {
|
|
18
|
+
// B-series burstable
|
|
19
|
+
Standard_B1ls: 3.8,
|
|
20
|
+
Standard_B1s: 7.59,
|
|
21
|
+
Standard_B1ms: 15.18,
|
|
22
|
+
Standard_B2s: 30.37,
|
|
23
|
+
Standard_B2ms: 60.74,
|
|
24
|
+
Standard_B4ms: 121.47,
|
|
25
|
+
Standard_B8ms: 242.94,
|
|
26
|
+
// D-series general purpose
|
|
27
|
+
Standard_D2s_v3: 69.35,
|
|
28
|
+
Standard_D4s_v3: 138.7,
|
|
29
|
+
Standard_D8s_v3: 277.4,
|
|
30
|
+
Standard_D16s_v3: 554.79,
|
|
31
|
+
Standard_D2s_v4: 69.35,
|
|
32
|
+
Standard_D4s_v4: 138.7,
|
|
33
|
+
Standard_D8s_v4: 277.4,
|
|
34
|
+
Standard_D2s_v5: 69.35,
|
|
35
|
+
Standard_D4s_v5: 138.7,
|
|
36
|
+
Standard_D8s_v5: 277.4,
|
|
37
|
+
// D-series (non-premium storage)
|
|
38
|
+
Standard_D2_v3: 65.7,
|
|
39
|
+
Standard_D4_v3: 131.4,
|
|
40
|
+
Standard_D2_v5: 65.7,
|
|
41
|
+
Standard_D4_v5: 131.4,
|
|
42
|
+
// E-series memory optimized
|
|
43
|
+
Standard_E2s_v3: 91.98,
|
|
44
|
+
Standard_E4s_v3: 183.96,
|
|
45
|
+
Standard_E8s_v3: 367.92,
|
|
46
|
+
Standard_E16s_v3: 735.84,
|
|
47
|
+
Standard_E2s_v5: 91.98,
|
|
48
|
+
Standard_E4s_v5: 183.96,
|
|
49
|
+
Standard_E8s_v5: 367.92,
|
|
50
|
+
// F-series compute optimized
|
|
51
|
+
Standard_F2s_v2: 60.59,
|
|
52
|
+
Standard_F4s_v2: 121.18,
|
|
53
|
+
Standard_F8s_v2: 242.36,
|
|
54
|
+
Standard_F16s_v2: 484.72,
|
|
55
|
+
// A-series basic
|
|
56
|
+
Standard_A1_v2: 29.2,
|
|
57
|
+
Standard_A2_v2: 61.32,
|
|
58
|
+
Standard_A4_v2: 128.48,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// ------------------------------------------------------------------
|
|
62
|
+
// Managed Disk pricing (per GB/month, East US)
|
|
63
|
+
// ------------------------------------------------------------------
|
|
64
|
+
const DISK_PRICING: Record<string, { price: number; type: 'fixed' | 'per-gb' }> = {
|
|
65
|
+
// Premium SSD managed disks (fixed per tier)
|
|
66
|
+
Premium_LRS: { price: 0.132, type: 'per-gb' },
|
|
67
|
+
StandardSSD_LRS: { price: 0.075, type: 'per-gb' },
|
|
68
|
+
Standard_LRS: { price: 0.04, type: 'per-gb' },
|
|
69
|
+
UltraSSD_LRS: { price: 0.12, type: 'per-gb' },
|
|
70
|
+
PremiumV2_LRS: { price: 0.12, type: 'per-gb' },
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Look up the estimated monthly price for an Azure Terraform resource.
|
|
75
|
+
*/
|
|
76
|
+
export function getAzurePrice(resource: TerraformResource): PricingResult | null {
|
|
77
|
+
const { type, attributes } = resource;
|
|
78
|
+
|
|
79
|
+
switch (type) {
|
|
80
|
+
// ----- Compute -----
|
|
81
|
+
case 'azurerm_virtual_machine':
|
|
82
|
+
case 'azurerm_linux_virtual_machine':
|
|
83
|
+
case 'azurerm_windows_virtual_machine': {
|
|
84
|
+
const vmSize = attributes.size || attributes.vm_size || 'Standard_D2s_v3';
|
|
85
|
+
const price = VM_PRICING[vmSize];
|
|
86
|
+
if (!price) {
|
|
87
|
+
return {
|
|
88
|
+
monthlyCost: 69.35,
|
|
89
|
+
hourlyCost: 69.35 / HOURS_PER_MONTH,
|
|
90
|
+
description: `VM ${vmSize} (estimated, size not in lookup table)`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const isWindows = type === 'azurerm_windows_virtual_machine';
|
|
94
|
+
const windowsSurcharge = isWindows ? price * 0.4 : 0; // ~40% Windows license surcharge
|
|
95
|
+
return {
|
|
96
|
+
monthlyCost: price + windowsSurcharge,
|
|
97
|
+
hourlyCost: (price + windowsSurcharge) / HOURS_PER_MONTH,
|
|
98
|
+
unit: 'hours',
|
|
99
|
+
description: `VM ${vmSize}${isWindows ? ' (Windows)' : ''}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
case 'azurerm_virtual_machine_scale_set':
|
|
104
|
+
case 'azurerm_linux_virtual_machine_scale_set':
|
|
105
|
+
case 'azurerm_windows_virtual_machine_scale_set': {
|
|
106
|
+
const vmSize = attributes.sku || attributes.size || 'Standard_D2s_v3';
|
|
107
|
+
const instances = attributes.instances || 2;
|
|
108
|
+
const price = VM_PRICING[vmSize] || 69.35;
|
|
109
|
+
return {
|
|
110
|
+
monthlyCost: price * instances,
|
|
111
|
+
hourlyCost: (price * instances) / HOURS_PER_MONTH,
|
|
112
|
+
quantity: instances,
|
|
113
|
+
unit: 'instances',
|
|
114
|
+
description: `VMSS ${vmSize} x${instances}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ----- Database -----
|
|
119
|
+
case 'azurerm_mssql_server': {
|
|
120
|
+
// SQL Server logical server has no direct cost
|
|
121
|
+
return {
|
|
122
|
+
monthlyCost: 0,
|
|
123
|
+
hourlyCost: 0,
|
|
124
|
+
description: 'SQL Server logical server (no direct cost)',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
case 'azurerm_mssql_database': {
|
|
129
|
+
// Estimate based on sku_name
|
|
130
|
+
const sku = attributes.sku_name || 'S0';
|
|
131
|
+
const sqlPricing: Record<string, number> = {
|
|
132
|
+
Basic: 4.9,
|
|
133
|
+
S0: 14.72,
|
|
134
|
+
S1: 29.43,
|
|
135
|
+
S2: 73.58,
|
|
136
|
+
S3: 147.17,
|
|
137
|
+
P1: 460.8,
|
|
138
|
+
P2: 921.6,
|
|
139
|
+
P4: 1843.2,
|
|
140
|
+
GP_S_Gen5_1: 38.35,
|
|
141
|
+
GP_S_Gen5_2: 76.7,
|
|
142
|
+
GP_Gen5_2: 307.68,
|
|
143
|
+
GP_Gen5_4: 615.36,
|
|
144
|
+
BC_Gen5_2: 716.8,
|
|
145
|
+
BC_Gen5_4: 1433.6,
|
|
146
|
+
};
|
|
147
|
+
const price = sqlPricing[sku] || 14.72;
|
|
148
|
+
return {
|
|
149
|
+
monthlyCost: price,
|
|
150
|
+
hourlyCost: price / HOURS_PER_MONTH,
|
|
151
|
+
description: `Azure SQL Database ${sku}`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
case 'azurerm_mysql_flexible_server':
|
|
156
|
+
case 'azurerm_postgresql_flexible_server': {
|
|
157
|
+
const sku = attributes.sku_name || 'B_Standard_B1ms';
|
|
158
|
+
const dbType = type.includes('mysql') ? 'MySQL' : 'PostgreSQL';
|
|
159
|
+
// Approximate pricing for flexible server
|
|
160
|
+
const flexPricing: Record<string, number> = {
|
|
161
|
+
B_Standard_B1s: 12.26,
|
|
162
|
+
B_Standard_B1ms: 15.33,
|
|
163
|
+
B_Standard_B2s: 30.66,
|
|
164
|
+
GP_Standard_D2s_v3: 101.47,
|
|
165
|
+
GP_Standard_D4s_v3: 202.94,
|
|
166
|
+
GP_Standard_D8s_v3: 405.88,
|
|
167
|
+
MO_Standard_E2s_v3: 128.11,
|
|
168
|
+
MO_Standard_E4s_v3: 256.23,
|
|
169
|
+
};
|
|
170
|
+
const price = flexPricing[sku] || 15.33;
|
|
171
|
+
const storageGB = attributes.storage_mb ? attributes.storage_mb / 1024 : 32;
|
|
172
|
+
const storageCost = storageGB * 0.115; // ~$0.115/GB/month
|
|
173
|
+
return {
|
|
174
|
+
monthlyCost: price + storageCost,
|
|
175
|
+
hourlyCost: price / HOURS_PER_MONTH,
|
|
176
|
+
description: `${dbType} Flexible Server ${sku} + ${storageGB}GB`,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
case 'azurerm_cosmosdb_account': {
|
|
181
|
+
// CosmosDB: estimate 400 RU/s provisioned
|
|
182
|
+
const rus = 400;
|
|
183
|
+
// $0.008/100 RU/hr
|
|
184
|
+
const cost = (rus / 100) * 0.008 * HOURS_PER_MONTH;
|
|
185
|
+
return {
|
|
186
|
+
monthlyCost: cost,
|
|
187
|
+
hourlyCost: (rus / 100) * 0.008,
|
|
188
|
+
description: `Cosmos DB (estimated ${rus} RU/s provisioned)`,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
case 'azurerm_redis_cache': {
|
|
193
|
+
const family = attributes.family || 'C';
|
|
194
|
+
const capacity = attributes.capacity || 0;
|
|
195
|
+
// Basic tier pricing
|
|
196
|
+
const redisPricing: Record<string, number> = {
|
|
197
|
+
C0: 16.06,
|
|
198
|
+
C1: 40.15,
|
|
199
|
+
C2: 60.22,
|
|
200
|
+
C3: 120.45,
|
|
201
|
+
C4: 240.9,
|
|
202
|
+
C5: 481.8,
|
|
203
|
+
C6: 963.6,
|
|
204
|
+
P1: 200.75,
|
|
205
|
+
P2: 401.5,
|
|
206
|
+
P3: 803.0,
|
|
207
|
+
P4: 1606.0,
|
|
208
|
+
};
|
|
209
|
+
const key = `${family}${capacity}`;
|
|
210
|
+
const price = redisPricing[key] || 16.06;
|
|
211
|
+
return {
|
|
212
|
+
monthlyCost: price,
|
|
213
|
+
hourlyCost: price / HOURS_PER_MONTH,
|
|
214
|
+
description: `Azure Cache for Redis ${key}`,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ----- Storage -----
|
|
219
|
+
case 'azurerm_storage_account': {
|
|
220
|
+
// Storage account: pricing depends on access tier and usage
|
|
221
|
+
// Estimate 100GB Hot tier
|
|
222
|
+
return {
|
|
223
|
+
monthlyCost: 2.08,
|
|
224
|
+
hourlyCost: 0,
|
|
225
|
+
unit: 'GB',
|
|
226
|
+
description: 'Storage Account (estimated 100GB Hot tier)',
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
case 'azurerm_managed_disk': {
|
|
231
|
+
const storageType = attributes.storage_account_type || 'Standard_LRS';
|
|
232
|
+
const diskSize = attributes.disk_size_gb || 32;
|
|
233
|
+
const diskInfo = DISK_PRICING[storageType];
|
|
234
|
+
const pricePerGB = diskInfo ? diskInfo.price : 0.04;
|
|
235
|
+
return {
|
|
236
|
+
monthlyCost: diskSize * pricePerGB,
|
|
237
|
+
hourlyCost: 0,
|
|
238
|
+
quantity: diskSize,
|
|
239
|
+
unit: 'GB',
|
|
240
|
+
description: `Managed Disk ${storageType} ${diskSize}GB`,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ----- Networking -----
|
|
245
|
+
case 'azurerm_lb':
|
|
246
|
+
case 'azurerm_lb_rule': {
|
|
247
|
+
const sku = attributes.sku || 'Standard';
|
|
248
|
+
if (sku === 'Basic') {
|
|
249
|
+
return { monthlyCost: 0, hourlyCost: 0, description: 'Load Balancer Basic (free)' };
|
|
250
|
+
}
|
|
251
|
+
// Standard LB: ~$0.025/hr + rules
|
|
252
|
+
return {
|
|
253
|
+
monthlyCost: 18.25 + 7.3,
|
|
254
|
+
hourlyCost: 0.025,
|
|
255
|
+
description: 'Load Balancer Standard (fixed + estimated rules)',
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
case 'azurerm_application_gateway': {
|
|
260
|
+
// App Gateway v2: ~$0.246/hr + capacity units
|
|
261
|
+
return {
|
|
262
|
+
monthlyCost: 179.58 + 43.8,
|
|
263
|
+
hourlyCost: 0.246,
|
|
264
|
+
description: 'Application Gateway v2 (fixed + estimated CU)',
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
case 'azurerm_public_ip': {
|
|
269
|
+
const sku = attributes.sku || 'Standard';
|
|
270
|
+
if (sku === 'Basic') {
|
|
271
|
+
return {
|
|
272
|
+
monthlyCost: 0,
|
|
273
|
+
hourlyCost: 0,
|
|
274
|
+
description: 'Public IP Basic (free when associated)',
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
// Standard: $0.005/hr
|
|
278
|
+
return {
|
|
279
|
+
monthlyCost: 3.65,
|
|
280
|
+
hourlyCost: 0.005,
|
|
281
|
+
description: 'Public IP Standard',
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
case 'azurerm_nat_gateway': {
|
|
286
|
+
// NAT Gateway: ~$0.045/hr + data processing
|
|
287
|
+
return {
|
|
288
|
+
monthlyCost: 32.85 + 32.85,
|
|
289
|
+
hourlyCost: 0.045,
|
|
290
|
+
description: 'NAT Gateway (fixed + estimated data processing)',
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
case 'azurerm_frontdoor':
|
|
295
|
+
case 'azurerm_cdn_frontdoor_profile': {
|
|
296
|
+
return {
|
|
297
|
+
monthlyCost: 35.04,
|
|
298
|
+
hourlyCost: 35.04 / HOURS_PER_MONTH,
|
|
299
|
+
description: 'Azure Front Door (estimated base fee)',
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
case 'azurerm_vpn_gateway': {
|
|
304
|
+
return {
|
|
305
|
+
monthlyCost: 138.7,
|
|
306
|
+
hourlyCost: 0.19,
|
|
307
|
+
description: 'VPN Gateway (VpnGw1)',
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
case 'azurerm_express_route_circuit': {
|
|
312
|
+
// ExpressRoute: varies wildly, estimate Standard 50Mbps Metered
|
|
313
|
+
return {
|
|
314
|
+
monthlyCost: 29.2,
|
|
315
|
+
hourlyCost: 0.04,
|
|
316
|
+
description: 'ExpressRoute (estimated Standard 50Mbps)',
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// ----- Containers -----
|
|
321
|
+
case 'azurerm_kubernetes_cluster': {
|
|
322
|
+
// AKS control plane is free for standard tier
|
|
323
|
+
// Cost comes from node pools
|
|
324
|
+
const sku = attributes.sku_tier || 'Free';
|
|
325
|
+
const cost = sku === 'Standard' ? 73.0 : 0;
|
|
326
|
+
return {
|
|
327
|
+
monthlyCost: cost,
|
|
328
|
+
hourlyCost: cost / HOURS_PER_MONTH,
|
|
329
|
+
description: `AKS cluster (${sku} tier)`,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
case 'azurerm_kubernetes_cluster_node_pool': {
|
|
334
|
+
const vmSize = attributes.vm_size || 'Standard_D2s_v3';
|
|
335
|
+
const nodeCount = attributes.node_count || attributes.min_count || 1;
|
|
336
|
+
const price = VM_PRICING[vmSize] || 69.35;
|
|
337
|
+
return {
|
|
338
|
+
monthlyCost: price * nodeCount,
|
|
339
|
+
hourlyCost: (price * nodeCount) / HOURS_PER_MONTH,
|
|
340
|
+
quantity: nodeCount,
|
|
341
|
+
unit: 'nodes',
|
|
342
|
+
description: `AKS node pool ${vmSize} x${nodeCount}`,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
case 'azurerm_container_registry': {
|
|
347
|
+
const sku = attributes.sku || 'Basic';
|
|
348
|
+
const acrPricing: Record<string, number> = {
|
|
349
|
+
Basic: 5.0,
|
|
350
|
+
Standard: 20.0,
|
|
351
|
+
Premium: 50.0,
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
monthlyCost: acrPricing[sku] || 5.0,
|
|
355
|
+
hourlyCost: 0,
|
|
356
|
+
description: `Container Registry ${sku}`,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
case 'azurerm_container_group': {
|
|
361
|
+
// ACI: estimate 1 vCPU, 1.5GB memory, running 730 hours
|
|
362
|
+
const cpuCores = attributes.cpu || 1;
|
|
363
|
+
const memoryGb = attributes.memory || 1.5;
|
|
364
|
+
// ~$0.0000125/vCPU-second, ~$0.0000015/GB-second
|
|
365
|
+
const cpuCost = cpuCores * 0.0000125 * 3600 * HOURS_PER_MONTH;
|
|
366
|
+
const memCost = memoryGb * 0.0000015 * 3600 * HOURS_PER_MONTH;
|
|
367
|
+
return {
|
|
368
|
+
monthlyCost: cpuCost + memCost,
|
|
369
|
+
hourlyCost: (cpuCost + memCost) / HOURS_PER_MONTH,
|
|
370
|
+
description: `Container Instance (${cpuCores} vCPU, ${memoryGb}GB)`,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// ----- Serverless -----
|
|
375
|
+
case 'azurerm_function_app':
|
|
376
|
+
case 'azurerm_linux_function_app':
|
|
377
|
+
case 'azurerm_windows_function_app': {
|
|
378
|
+
return {
|
|
379
|
+
monthlyCost: 0,
|
|
380
|
+
hourlyCost: 0,
|
|
381
|
+
description: 'Function App (consumption plan, usage-based)',
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
case 'azurerm_servicebus_namespace': {
|
|
386
|
+
const sku = attributes.sku || 'Basic';
|
|
387
|
+
const sbPricing: Record<string, number> = {
|
|
388
|
+
Basic: 0.05,
|
|
389
|
+
Standard: 9.81,
|
|
390
|
+
Premium: 668.26,
|
|
391
|
+
};
|
|
392
|
+
return {
|
|
393
|
+
monthlyCost: sbPricing[sku] || 0.05,
|
|
394
|
+
hourlyCost: 0,
|
|
395
|
+
description: `Service Bus ${sku}`,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
case 'azurerm_eventhub_namespace': {
|
|
400
|
+
const sku = attributes.sku || 'Basic';
|
|
401
|
+
const capacity = attributes.capacity || 1;
|
|
402
|
+
const ehPricing: Record<string, number> = {
|
|
403
|
+
Basic: 10.95,
|
|
404
|
+
Standard: 21.9,
|
|
405
|
+
Premium: 876.0,
|
|
406
|
+
};
|
|
407
|
+
const base = ehPricing[sku] || 10.95;
|
|
408
|
+
return {
|
|
409
|
+
monthlyCost: base * capacity,
|
|
410
|
+
hourlyCost: (base * capacity) / HOURS_PER_MONTH,
|
|
411
|
+
quantity: capacity,
|
|
412
|
+
unit: 'throughput units',
|
|
413
|
+
description: `Event Hubs ${sku} (${capacity} TU)`,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// ----- App Service -----
|
|
418
|
+
case 'azurerm_service_plan': {
|
|
419
|
+
const skuName = attributes.sku_name || 'B1';
|
|
420
|
+
const aspPricing: Record<string, number> = {
|
|
421
|
+
F1: 0,
|
|
422
|
+
D1: 9.49,
|
|
423
|
+
B1: 13.14,
|
|
424
|
+
B2: 26.28,
|
|
425
|
+
B3: 52.56,
|
|
426
|
+
S1: 73.0,
|
|
427
|
+
S2: 146.0,
|
|
428
|
+
S3: 292.0,
|
|
429
|
+
P1v2: 73.0,
|
|
430
|
+
P2v2: 146.0,
|
|
431
|
+
P3v2: 292.0,
|
|
432
|
+
P1v3: 102.2,
|
|
433
|
+
P2v3: 204.4,
|
|
434
|
+
P3v3: 408.8,
|
|
435
|
+
};
|
|
436
|
+
return {
|
|
437
|
+
monthlyCost: aspPricing[skuName] || 13.14,
|
|
438
|
+
hourlyCost: (aspPricing[skuName] || 13.14) / HOURS_PER_MONTH,
|
|
439
|
+
description: `App Service Plan ${skuName}`,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
case 'azurerm_linux_web_app':
|
|
444
|
+
case 'azurerm_windows_web_app': {
|
|
445
|
+
return {
|
|
446
|
+
monthlyCost: 0,
|
|
447
|
+
hourlyCost: 0,
|
|
448
|
+
description: 'Web App (cost included in Service Plan)',
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// ----- Monitoring -----
|
|
453
|
+
case 'azurerm_log_analytics_workspace': {
|
|
454
|
+
// Free tier: 5GB/month; Pay-as-you-go: ~$2.76/GB
|
|
455
|
+
return {
|
|
456
|
+
monthlyCost: 0,
|
|
457
|
+
hourlyCost: 0,
|
|
458
|
+
description: 'Log Analytics Workspace (ingestion usage-based, 5GB free)',
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
case 'azurerm_application_insights': {
|
|
463
|
+
return {
|
|
464
|
+
monthlyCost: 0,
|
|
465
|
+
hourlyCost: 0,
|
|
466
|
+
description: 'Application Insights (ingestion usage-based, 5GB free)',
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
case 'azurerm_monitor_action_group':
|
|
471
|
+
case 'azurerm_monitor_metric_alert': {
|
|
472
|
+
return { monthlyCost: 0, hourlyCost: 0, description: 'Monitor resource (minimal cost)' };
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// ----- Identity / Security / Networking (no direct cost) -----
|
|
476
|
+
case 'azurerm_resource_group':
|
|
477
|
+
case 'azurerm_virtual_network':
|
|
478
|
+
case 'azurerm_subnet':
|
|
479
|
+
case 'azurerm_network_security_group':
|
|
480
|
+
case 'azurerm_network_security_rule':
|
|
481
|
+
case 'azurerm_route_table':
|
|
482
|
+
case 'azurerm_network_interface':
|
|
483
|
+
case 'azurerm_user_assigned_identity':
|
|
484
|
+
case 'azurerm_role_assignment':
|
|
485
|
+
case 'azurerm_key_vault':
|
|
486
|
+
case 'azurerm_key_vault_secret':
|
|
487
|
+
case 'azurerm_key_vault_key':
|
|
488
|
+
case 'azurerm_dns_zone':
|
|
489
|
+
case 'azurerm_dns_a_record':
|
|
490
|
+
case 'azurerm_dns_cname_record':
|
|
491
|
+
case 'azurerm_private_dns_zone':
|
|
492
|
+
case 'azurerm_private_endpoint': {
|
|
493
|
+
return { monthlyCost: 0, hourlyCost: 0, description: 'No direct cost' };
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
default:
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
}
|