cdk-cost-analyzer 0.1.35 → 0.1.37

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 (89) hide show
  1. package/.cdk-cost-analyzer-cache/metadata.json +8 -8
  2. package/README.md +193 -3
  3. package/action.yml +50 -0
  4. package/dist/action/136.index.js +936 -0
  5. package/dist/action/360.index.js +93 -0
  6. package/dist/action/443.index.js +780 -0
  7. package/dist/action/566.index.js +387 -0
  8. package/dist/action/579.index.js +270 -0
  9. package/dist/action/605.index.js +234 -0
  10. package/dist/action/762.index.js +632 -0
  11. package/dist/action/869.index.js +531 -0
  12. package/dist/action/956.index.js +1072 -0
  13. package/dist/action/998.index.js +1418 -0
  14. package/dist/action/action/index.d.ts +7 -0
  15. package/dist/action/analysis/SingleTemplateAnalyzer.d.ts +23 -0
  16. package/dist/action/analysis/index.d.ts +1 -0
  17. package/dist/action/api/index.d.ts +35 -0
  18. package/dist/action/api/single-template-types.d.ts +83 -0
  19. package/dist/action/api/types.d.ts +15 -0
  20. package/dist/action/cli/index.d.ts +2 -0
  21. package/dist/action/config/ConfigManager.d.ts +40 -0
  22. package/dist/action/config/index.d.ts +2 -0
  23. package/dist/action/config/types.d.ts +153 -0
  24. package/dist/action/diff/DiffEngine.d.ts +7 -0
  25. package/dist/action/diff/index.d.ts +2 -0
  26. package/dist/action/diff/types.d.ts +20 -0
  27. package/dist/action/index.d.ts +8 -0
  28. package/dist/action/index.js +4 -0
  29. package/dist/action/integrations/GitHubIntegration.d.ts +43 -0
  30. package/dist/action/integrations/GitLabIntegration.d.ts +7 -0
  31. package/dist/action/integrations/index.d.ts +3 -0
  32. package/dist/action/integrations/types.d.ts +40 -0
  33. package/dist/action/parser/TemplateParser.d.ts +8 -0
  34. package/dist/action/parser/index.d.ts +2 -0
  35. package/dist/action/parser/types.d.ts +30 -0
  36. package/dist/action/pipeline/PipelineOrchestrator.d.ts +23 -0
  37. package/dist/action/pipeline/index.d.ts +2 -0
  38. package/dist/action/pipeline/types.d.ts +41 -0
  39. package/dist/action/pricing/CacheManager.d.ts +75 -0
  40. package/dist/action/pricing/PricingClient.d.ts +17 -0
  41. package/dist/action/pricing/PricingService.d.ts +16 -0
  42. package/dist/action/pricing/RegionMapper.d.ts +14 -0
  43. package/dist/action/pricing/calculators/ALBCalculator.d.ts +15 -0
  44. package/dist/action/pricing/calculators/APIGatewayCalculator.d.ts +9 -0
  45. package/dist/action/pricing/calculators/AutoScalingGroupCalculator.d.ts +9 -0
  46. package/dist/action/pricing/calculators/CloudFrontCalculator.d.ts +49 -0
  47. package/dist/action/pricing/calculators/DynamoDBCalculator.d.ts +12 -0
  48. package/dist/action/pricing/calculators/EC2Calculator.d.ts +6 -0
  49. package/dist/action/pricing/calculators/ECSCalculator.d.ts +8 -0
  50. package/dist/action/pricing/calculators/EFSCalculator.d.ts +19 -0
  51. package/dist/action/pricing/calculators/ElastiCacheCalculator.d.ts +7 -0
  52. package/dist/action/pricing/calculators/LambdaCalculator.d.ts +14 -0
  53. package/dist/action/pricing/calculators/LaunchTemplateCalculator.d.ts +35 -0
  54. package/dist/action/pricing/calculators/NLBCalculator.d.ts +15 -0
  55. package/dist/action/pricing/calculators/NatGatewayCalculator.d.ts +10 -0
  56. package/dist/action/pricing/calculators/RDSCalculator.d.ts +8 -0
  57. package/dist/action/pricing/calculators/S3Calculator.d.ts +7 -0
  58. package/dist/action/pricing/calculators/SNSCalculator.d.ts +54 -0
  59. package/dist/action/pricing/calculators/SQSCalculator.d.ts +16 -0
  60. package/dist/action/pricing/calculators/SecretsManagerCalculator.d.ts +21 -0
  61. package/dist/action/pricing/calculators/StepFunctionsCalculator.d.ts +23 -0
  62. package/dist/action/pricing/calculators/VPCEndpointCalculator.d.ts +10 -0
  63. package/dist/action/pricing/index.d.ts +16 -0
  64. package/dist/action/pricing/types.d.ts +54 -0
  65. package/dist/action/reporter/GitHubActionReporter.d.ts +42 -0
  66. package/dist/action/reporter/Reporter.d.ts +18 -0
  67. package/dist/action/reporter/SingleTemplateReporter.d.ts +31 -0
  68. package/dist/action/reporter/index.d.ts +4 -0
  69. package/dist/action/reporter/types.d.ts +72 -0
  70. package/dist/action/synthesis/SynthesisOrchestrator.d.ts +26 -0
  71. package/dist/action/synthesis/index.d.ts +2 -0
  72. package/dist/action/synthesis/types.d.ts +17 -0
  73. package/dist/action/threshold/ThresholdEnforcer.d.ts +29 -0
  74. package/dist/action/threshold/index.d.ts +2 -0
  75. package/dist/action/threshold/types.d.ts +15 -0
  76. package/dist/action/utils/Logger.d.ts +39 -0
  77. package/dist/cli/index.js +56 -1
  78. package/dist/integrations/GitHubIntegration.d.ts +43 -0
  79. package/dist/integrations/GitHubIntegration.js +217 -0
  80. package/dist/integrations/index.d.ts +1 -0
  81. package/dist/integrations/index.js +4 -2
  82. package/dist/integrations/types.d.ts +29 -0
  83. package/dist/integrations/types.js +11 -2
  84. package/dist/releasetag.txt +1 -1
  85. package/dist/reporter/GitHubActionReporter.d.ts +42 -0
  86. package/dist/reporter/GitHubActionReporter.js +161 -0
  87. package/dist/reporter/index.d.ts +1 -0
  88. package/dist/reporter/index.js +4 -2
  89. package/package.json +5 -1
@@ -0,0 +1,43 @@
1
+ import { GitHubIntegration as IGitHubIntegration, GitHubConfig, GitHubComment, CommentStrategy } from './types';
2
+ export declare class GitHubIntegration implements IGitHubIntegration {
3
+ /**
4
+ * Create a GitHubIntegration instance from environment variables.
5
+ * Looks for GITHUB_TOKEN environment variable.
6
+ */
7
+ static fromEnvironment(): GitHubIntegration;
8
+ private config;
9
+ constructor(config: GitHubConfig);
10
+ /**
11
+ * Post a comment to a pull request using the specified strategy.
12
+ */
13
+ postPRComment(owner: string, repo: string, prNumber: number, comment: string, strategy?: CommentStrategy): Promise<void>;
14
+ /**
15
+ * Find an existing cost analyzer comment on a PR.
16
+ * Supports pagination for PRs with many comments.
17
+ */
18
+ findExistingComment(owner: string, repo: string, prNumber: number): Promise<GitHubComment | null>;
19
+ /**
20
+ * Update an existing comment.
21
+ */
22
+ updateComment(owner: string, repo: string, commentId: number, comment: string): Promise<void>;
23
+ /**
24
+ * Delete a comment.
25
+ */
26
+ deleteComment(owner: string, repo: string, commentId: number): Promise<void>;
27
+ /**
28
+ * Create a new comment on a PR.
29
+ */
30
+ private createComment;
31
+ /**
32
+ * Get headers for GitHub API requests.
33
+ */
34
+ private getHeaders;
35
+ /**
36
+ * Fetch with retry logic for rate limiting.
37
+ */
38
+ private fetchWithRetry;
39
+ /**
40
+ * Sanitize error messages to prevent token leakage.
41
+ */
42
+ private sanitizeError;
43
+ }
@@ -0,0 +1,7 @@
1
+ import { GitLabIntegration as IGitLabIntegration, GitLabConfig } from './types';
2
+ export declare class GitLabIntegration implements IGitLabIntegration {
3
+ static fromEnvironment(): GitLabIntegration;
4
+ private config;
5
+ constructor(config: GitLabConfig);
6
+ postMergeRequestComment(projectId: string, mergeRequestIid: string, comment: string): Promise<void>;
7
+ }
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export { GitLabIntegration } from './GitLabIntegration';
3
+ export { GitHubIntegration } from './GitHubIntegration';
@@ -0,0 +1,40 @@
1
+ export interface GitLabIntegration {
2
+ postMergeRequestComment(projectId: string, mergeRequestIid: string, comment: string): Promise<void>;
3
+ }
4
+ export interface GitLabConfig {
5
+ token: string;
6
+ apiUrl: string;
7
+ }
8
+ export declare class GitLabAPIError extends Error {
9
+ statusCode?: number | undefined;
10
+ constructor(message: string, statusCode?: number | undefined);
11
+ }
12
+ /**
13
+ * Comment strategy for GitHub PR comments
14
+ * - 'new': Always create a new comment
15
+ * - 'update': Find and update existing comment, or create new if not found
16
+ * - 'delete-and-new': Delete existing comment and create a new one
17
+ */
18
+ export type CommentStrategy = 'new' | 'update' | 'delete-and-new';
19
+ export interface GitHubIntegration {
20
+ postPRComment(owner: string, repo: string, prNumber: number, comment: string, strategy: CommentStrategy): Promise<void>;
21
+ findExistingComment(owner: string, repo: string, prNumber: number): Promise<GitHubComment | null>;
22
+ updateComment(owner: string, repo: string, commentId: number, comment: string): Promise<void>;
23
+ deleteComment(owner: string, repo: string, commentId: number): Promise<void>;
24
+ }
25
+ export interface GitHubConfig {
26
+ token: string;
27
+ apiUrl: string;
28
+ }
29
+ export interface GitHubComment {
30
+ id: number;
31
+ body: string;
32
+ user: {
33
+ login: string;
34
+ type: string;
35
+ };
36
+ }
37
+ export declare class GitHubAPIError extends Error {
38
+ statusCode?: number | undefined;
39
+ constructor(message: string, statusCode?: number | undefined);
40
+ }
@@ -0,0 +1,8 @@
1
+ import { CloudFormationTemplate, TemplateParser as ITemplateParser } from './types';
2
+ export declare class TemplateParseError extends Error {
3
+ templatePath?: string | undefined;
4
+ constructor(message: string, templatePath?: string | undefined);
5
+ }
6
+ export declare class TemplateParser implements ITemplateParser {
7
+ parse(content: string): CloudFormationTemplate;
8
+ }
@@ -0,0 +1,2 @@
1
+ export { TemplateParser, TemplateParseError } from './TemplateParser';
2
+ export * from './types';
@@ -0,0 +1,30 @@
1
+ export interface CloudFormationTemplate {
2
+ AWSTemplateFormatVersion?: string;
3
+ Description?: string;
4
+ Metadata?: Record<string, unknown>;
5
+ Parameters?: Record<string, Parameter>;
6
+ Resources: Record<string, Resource>;
7
+ Outputs?: Record<string, Output>;
8
+ }
9
+ export interface Resource {
10
+ Type: string;
11
+ Properties: Record<string, unknown>;
12
+ DependsOn?: string | string[];
13
+ Metadata?: Record<string, unknown>;
14
+ }
15
+ export interface Parameter {
16
+ Type: string;
17
+ Default?: unknown;
18
+ Description?: string;
19
+ AllowedValues?: unknown[];
20
+ }
21
+ export interface Output {
22
+ Value: unknown;
23
+ Description?: string;
24
+ Export?: {
25
+ Name: string;
26
+ };
27
+ }
28
+ export interface TemplateParser {
29
+ parse(content: string): CloudFormationTemplate;
30
+ }
@@ -0,0 +1,23 @@
1
+ import { PipelineOptions, PipelineResult } from './types';
2
+ export declare class PipelineOrchestrator {
3
+ private configManager;
4
+ private synthesisOrchestrator;
5
+ private thresholdEnforcer;
6
+ constructor();
7
+ /**
8
+ * Run complete pipeline analysis
9
+ */
10
+ runPipelineAnalysis(options: PipelineOptions): Promise<PipelineResult>;
11
+ /**
12
+ * Synthesize both base and target branches
13
+ */
14
+ private synthesizeBothBranches;
15
+ /**
16
+ * Analyze costs between two templates
17
+ */
18
+ private analyzeCosts;
19
+ /**
20
+ * Build configuration summary
21
+ */
22
+ private buildConfigSummary;
23
+ }
@@ -0,0 +1,2 @@
1
+ export * from './PipelineOrchestrator';
2
+ export * from './types';
@@ -0,0 +1,41 @@
1
+ import { CostAnalysisResult } from '../api/types';
2
+ import { ThresholdEvaluation } from '../threshold/types';
3
+ export interface PipelineOptions {
4
+ baseTemplate?: string;
5
+ targetTemplate?: string;
6
+ baseBranch?: string;
7
+ targetBranch?: string;
8
+ cdkAppPath?: string;
9
+ outputPath?: string;
10
+ configPath?: string;
11
+ region?: string;
12
+ synthesize?: boolean;
13
+ environment?: string;
14
+ }
15
+ export interface PipelineResult {
16
+ costAnalysis: CostAnalysisResult;
17
+ thresholdStatus: ThresholdEvaluation;
18
+ synthesisInfo?: SynthesisInfo;
19
+ configUsed: ConfigSummary;
20
+ }
21
+ export interface SynthesisInfo {
22
+ baseStackCount: number;
23
+ targetStackCount: number;
24
+ baseSynthesisTime: number;
25
+ targetSynthesisTime: number;
26
+ }
27
+ export interface ConfigSummary {
28
+ configPath?: string;
29
+ thresholds?: {
30
+ warning?: number;
31
+ error?: number;
32
+ environment?: string;
33
+ };
34
+ usageAssumptions?: Record<string, unknown>;
35
+ excludedResourceTypes?: string[];
36
+ synthesisEnabled: boolean;
37
+ }
38
+ export declare class PipelineError extends Error {
39
+ stage: string;
40
+ constructor(message: string, stage: string);
41
+ }
@@ -0,0 +1,75 @@
1
+ import { PriceQueryParams } from './types';
2
+ export interface CachedPriceEntry {
3
+ price: number;
4
+ timestamp: number;
5
+ }
6
+ export interface CacheMetadata {
7
+ entries: Record<string, CachedPriceEntry>;
8
+ }
9
+ /**
10
+ * Manages persistent caching of pricing data to reduce AWS API calls
11
+ * and improve performance across pipeline runs.
12
+ */
13
+ export declare class CacheManager {
14
+ private cacheDir;
15
+ private cacheDurationMs;
16
+ private metadata;
17
+ private metadataPath;
18
+ /**
19
+ * Creates a new CacheManager instance
20
+ * @param cacheDir Directory to store cache files (default: .cdk-cost-analyzer-cache)
21
+ * @param cacheDurationHours Duration in hours before cache entries expire (default: 24)
22
+ */
23
+ constructor(cacheDir?: string, cacheDurationHours?: number);
24
+ /**
25
+ * Retrieves a cached price if it exists and is still fresh
26
+ * @param params Price query parameters
27
+ * @returns Cached price or null if not found or expired
28
+ */
29
+ getCachedPrice(params: PriceQueryParams): number | null;
30
+ /**
31
+ * Stores a price in the cache with current timestamp
32
+ * @param params Price query parameters
33
+ * @param price Price value to cache
34
+ */
35
+ setCachedPrice(params: PriceQueryParams, price: number): void;
36
+ /**
37
+ * Checks if a cached price exists and is still fresh
38
+ * @param params Price query parameters
39
+ * @returns true if fresh cache entry exists
40
+ */
41
+ hasFreshCache(params: PriceQueryParams): boolean;
42
+ /**
43
+ * Clears all cached entries
44
+ */
45
+ clearCache(): void;
46
+ /**
47
+ * Gets cache statistics
48
+ * @returns Object with cache statistics
49
+ */
50
+ getCacheStats(): {
51
+ totalEntries: number;
52
+ freshEntries: number;
53
+ staleEntries: number;
54
+ };
55
+ /**
56
+ * Removes stale cache entries
57
+ */
58
+ pruneStaleEntries(): void;
59
+ /**
60
+ * Generates a cache key from price query parameters
61
+ */
62
+ private getCacheKey;
63
+ /**
64
+ * Ensures the cache directory exists
65
+ */
66
+ private ensureCacheDirectory;
67
+ /**
68
+ * Loads cache metadata from disk
69
+ */
70
+ private loadMetadata;
71
+ /**
72
+ * Saves cache metadata to disk
73
+ */
74
+ private saveMetadata;
75
+ }
@@ -0,0 +1,17 @@
1
+ import { PricingClient as AWSPricingClient } from '@aws-sdk/client-pricing';
2
+ import { CacheManager } from './CacheManager';
3
+ import { PricingClient as IPricingClient, PriceQueryParams } from './types';
4
+ export declare class PricingClient implements IPricingClient {
5
+ private cache;
6
+ private client;
7
+ private cacheManager?;
8
+ constructor(region?: string, cacheManager?: CacheManager, awsClient?: AWSPricingClient);
9
+ /**
10
+ * Clean up resources and connections
11
+ */
12
+ destroy(): void;
13
+ getPrice(params: PriceQueryParams): Promise<number | null>;
14
+ private fetchPriceWithRetry;
15
+ private fetchPrice;
16
+ private getCacheKey;
17
+ }
@@ -0,0 +1,16 @@
1
+ import { PricingClient } from './PricingClient';
2
+ import { PricingService as IPricingService, MonthlyCost, CostDelta } from './types';
3
+ import { UsageAssumptionsConfig, CacheConfig } from '../config/types';
4
+ import { ResourceWithId, ResourceDiff } from '../diff/types';
5
+ export declare class PricingService implements IPricingService {
6
+ private calculators;
7
+ private pricingClient;
8
+ private excludedResourceTypes;
9
+ constructor(region?: string, usageAssumptions?: UsageAssumptionsConfig, excludedResourceTypes?: string[], cacheConfig?: CacheConfig, pricingClient?: PricingClient);
10
+ getResourceCost(resource: ResourceWithId, region: string, templateResources?: ResourceWithId[]): Promise<MonthlyCost>;
11
+ getCostDelta(diff: ResourceDiff, region: string): Promise<CostDelta>;
12
+ /**
13
+ * Clean up resources and connections
14
+ */
15
+ destroy(): void;
16
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Normalize AWS region code to Pricing API region name
3
+ * Logs the normalization step when debug mode is enabled
4
+ */
5
+ export declare function normalizeRegion(region: string): string;
6
+ /**
7
+ * Get the AWS region prefix for pricing usagetype values.
8
+ * AWS uses region prefixes in usagetype values (e.g., USE1-ApiGatewayRequest).
9
+ * Reference: https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-region-billing-codes.html
10
+ *
11
+ * @param region - AWS region code (e.g., 'us-east-1', 'eu-west-1')
12
+ * @returns The usagetype prefix for the region, or empty string for unknown regions
13
+ */
14
+ export declare function getRegionPrefix(region: string): string;
@@ -0,0 +1,15 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class ALBCalculator implements ResourceCostCalculator {
4
+ private customNewConnectionsPerSecond?;
5
+ private customActiveConnectionsPerMinute?;
6
+ private customProcessedBytesGB?;
7
+ private readonly DEFAULT_NEW_CONNECTIONS_PER_SECOND;
8
+ private readonly DEFAULT_ACTIVE_CONNECTIONS_PER_MINUTE;
9
+ private readonly DEFAULT_PROCESSED_BYTES_GB;
10
+ private readonly HOURS_PER_MONTH;
11
+ constructor(customNewConnectionsPerSecond?: number | undefined, customActiveConnectionsPerMinute?: number | undefined, customProcessedBytesGB?: number | undefined);
12
+ supports(resourceType: string): boolean;
13
+ canCalculate(resource: ResourceWithId): boolean;
14
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
15
+ }
@@ -0,0 +1,9 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class APIGatewayCalculator implements ResourceCostCalculator {
4
+ supports(resourceType: string): boolean;
5
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
6
+ private calculateRestApiCost;
7
+ private calculateHttpApiCost;
8
+ private calculateWebSocketCost;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class AutoScalingGroupCalculator implements ResourceCostCalculator {
4
+ supports(resourceType: string): boolean;
5
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient, templateResources?: ResourceWithId[]): Promise<MonthlyCost>;
6
+ private resolveInstanceType;
7
+ private resolveInstanceTypeFromLaunchTemplate;
8
+ private resolveReference;
9
+ }
@@ -0,0 +1,49 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ /**
4
+ * Calculator for AWS CloudFront distribution costs.
5
+ *
6
+ * Estimates monthly costs based on data transfer and request volumes.
7
+ * CloudFront pricing includes:
8
+ * - Data transfer out to internet (per GB)
9
+ * - HTTP/HTTPS requests (per 10,000 requests)
10
+ *
11
+ * @see https://aws.amazon.com/cloudfront/pricing/
12
+ */
13
+ export declare class CloudFrontCalculator implements ResourceCostCalculator {
14
+ private readonly dataTransferGB?;
15
+ private readonly requests?;
16
+ private readonly DEFAULT_DATA_TRANSFER_GB;
17
+ private readonly DEFAULT_REQUESTS;
18
+ /**
19
+ * Creates a CloudFront cost calculator.
20
+ *
21
+ * @param dataTransferGB - Optional custom data transfer volume in GB per month
22
+ * @param requests - Optional custom request count per month
23
+ */
24
+ constructor(dataTransferGB?: number | undefined, requests?: number | undefined);
25
+ /**
26
+ * Checks if this calculator supports the given resource type.
27
+ *
28
+ * @param resourceType - CloudFormation resource type
29
+ * @returns true if resource type is AWS::CloudFront::Distribution
30
+ */
31
+ supports(resourceType: string): boolean;
32
+ /**
33
+ * Calculates monthly cost for a CloudFront distribution.
34
+ *
35
+ * Cost components:
36
+ * - Data transfer out to internet (based on volume in GB)
37
+ * - HTTP/HTTPS requests (per 10,000 requests)
38
+ *
39
+ * Default assumptions:
40
+ * - 100 GB data transfer per month
41
+ * - 1,000,000 requests per month
42
+ *
43
+ * @param _resource - CloudFormation resource (properties not used for CloudFront)
44
+ * @param region - AWS region for pricing (CloudFront is global but pricing varies by region)
45
+ * @param pricingClient - Client for querying AWS Pricing API
46
+ * @returns Monthly cost estimate with assumptions and confidence level
47
+ */
48
+ calculateCost(_resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
49
+ }
@@ -0,0 +1,12 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ import { CostAnalyzerConfig } from '../../config/types';
4
+ export declare class DynamoDBCalculator implements ResourceCostCalculator {
5
+ private config?;
6
+ constructor(config?: CostAnalyzerConfig);
7
+ supports(resourceType: string): boolean;
8
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
9
+ private getUsageAssumptions;
10
+ private calculateOnDemandCost;
11
+ private calculateProvisionedCost;
12
+ }
@@ -0,0 +1,6 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class EC2Calculator implements ResourceCostCalculator {
4
+ supports(resourceType: string): boolean;
5
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
6
+ }
@@ -0,0 +1,8 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class ECSCalculator implements ResourceCostCalculator {
4
+ supports(resourceType: string): boolean;
5
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
6
+ private calculateFargateCost;
7
+ private calculateEC2Cost;
8
+ }
@@ -0,0 +1,19 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export interface EFSUsageAssumptions {
4
+ storageSizeGb?: number;
5
+ infrequentAccessPercentage?: number;
6
+ }
7
+ export declare class EFSCalculator implements ResourceCostCalculator {
8
+ private readonly customStorageSizeGb?;
9
+ private readonly customInfrequentAccessPercentage?;
10
+ private readonly DEFAULT_STORAGE_SIZE_GB;
11
+ private readonly DEFAULT_IA_PERCENTAGE;
12
+ private readonly FALLBACK_STANDARD_PRICE;
13
+ private readonly FALLBACK_IA_STORAGE_PRICE;
14
+ private readonly FALLBACK_IA_REQUEST_PRICE;
15
+ private readonly FALLBACK_PROVISIONED_THROUGHPUT_PRICE;
16
+ constructor(customStorageSizeGb?: number | undefined, customInfrequentAccessPercentage?: number | undefined);
17
+ supports(resourceType: string): boolean;
18
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
19
+ }
@@ -0,0 +1,7 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class ElastiCacheCalculator implements ResourceCostCalculator {
4
+ supports(resourceType: string): boolean;
5
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
6
+ private normalizeEngine;
7
+ }
@@ -0,0 +1,14 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class LambdaCalculator implements ResourceCostCalculator {
4
+ private readonly customInvocationsPerMonth?;
5
+ private readonly customAverageDurationMs?;
6
+ private readonly DEFAULT_INVOCATIONS;
7
+ private readonly DEFAULT_DURATION_MS;
8
+ private readonly DEFAULT_MEMORY_MB;
9
+ private readonly FALLBACK_REQUEST_PRICE;
10
+ private readonly FALLBACK_COMPUTE_PRICE;
11
+ constructor(customInvocationsPerMonth?: number | undefined, customAverageDurationMs?: number | undefined);
12
+ supports(resourceType: string): boolean;
13
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
14
+ }
@@ -0,0 +1,35 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ /**
4
+ * Configuration extracted from a LaunchTemplate's LaunchTemplateData.
5
+ * This interface can be used by other calculators (e.g., AutoScalingGroupCalculator)
6
+ * to reference instance configuration.
7
+ */
8
+ export interface LaunchTemplateConfig {
9
+ instanceType: string | null;
10
+ imageId: string | null;
11
+ ebsVolumes: EbsVolumeConfig[];
12
+ }
13
+ export interface EbsVolumeConfig {
14
+ deviceName: string;
15
+ volumeType: string;
16
+ volumeSizeGB: number;
17
+ iops?: number;
18
+ throughput?: number;
19
+ deleteOnTermination: boolean;
20
+ }
21
+ export declare class LaunchTemplateCalculator implements ResourceCostCalculator {
22
+ private static readonly DEFAULT_VOLUME_SIZE_GB;
23
+ private static readonly DEFAULT_VOLUME_TYPE;
24
+ private static readonly MONTHLY_HOURS;
25
+ supports(resourceType: string): boolean;
26
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
27
+ /**
28
+ * Extract configuration from a LaunchTemplate resource.
29
+ * This method is public to allow other calculators to use it.
30
+ */
31
+ extractConfig(resource: ResourceWithId): LaunchTemplateConfig;
32
+ private extractEbsVolumes;
33
+ private calculateInstanceCost;
34
+ private calculateStorageCost;
35
+ }
@@ -0,0 +1,15 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class NLBCalculator implements ResourceCostCalculator {
4
+ private customNewConnectionsPerSecond?;
5
+ private customActiveConnectionsPerMinute?;
6
+ private customProcessedBytesGB?;
7
+ private readonly DEFAULT_NEW_CONNECTIONS_PER_SECOND;
8
+ private readonly DEFAULT_ACTIVE_CONNECTIONS_PER_MINUTE;
9
+ private readonly DEFAULT_PROCESSED_BYTES_GB;
10
+ private readonly HOURS_PER_MONTH;
11
+ constructor(customNewConnectionsPerSecond?: number | undefined, customActiveConnectionsPerMinute?: number | undefined, customProcessedBytesGB?: number | undefined);
12
+ supports(resourceType: string): boolean;
13
+ canCalculate(resource: ResourceWithId): boolean;
14
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
15
+ }
@@ -0,0 +1,10 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class NatGatewayCalculator implements ResourceCostCalculator {
4
+ private customDataProcessedGB?;
5
+ private readonly DEFAULT_DATA_PROCESSED_GB;
6
+ private readonly HOURS_PER_MONTH;
7
+ constructor(customDataProcessedGB?: number | undefined);
8
+ supports(resourceType: string): boolean;
9
+ calculateCost(_resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class RDSCalculator implements ResourceCostCalculator {
4
+ private readonly DEFAULT_STORAGE_GB;
5
+ supports(resourceType: string): boolean;
6
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
7
+ private normalizeEngine;
8
+ }
@@ -0,0 +1,7 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ export declare class S3Calculator implements ResourceCostCalculator {
4
+ private readonly DEFAULT_STORAGE_GB;
5
+ supports(resourceType: string): boolean;
6
+ calculateCost(_resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
7
+ }
@@ -0,0 +1,54 @@
1
+ import { ResourceWithId } from '../../diff/types';
2
+ import { ResourceCostCalculator, MonthlyCost, PricingClient } from '../types';
3
+ /**
4
+ * Cost breakdown for SNS pricing components
5
+ */
6
+ export interface SNSCostBreakdown {
7
+ publishCost: number;
8
+ httpDeliveryCost: number;
9
+ emailDeliveryCost: number;
10
+ smsDeliveryCost: number;
11
+ mobilePushDeliveryCost: number;
12
+ totalCost: number;
13
+ }
14
+ /**
15
+ * Calculator for AWS::SNS::Topic resources.
16
+ *
17
+ * SNS Pricing Model (as of 2024):
18
+ * - Publishes: $0.50 per million requests (first 1M free)
19
+ * - HTTP/S deliveries: $0.60 per million
20
+ * - Email deliveries: $2.00 per 100,000
21
+ * - SMS: Varies by country (using US rate as default)
22
+ * - Mobile push: $0.50 per million
23
+ *
24
+ * @see https://aws.amazon.com/sns/pricing/
25
+ */
26
+ export declare class SNSCalculator implements ResourceCostCalculator {
27
+ private readonly customMonthlyPublishes?;
28
+ private readonly customHttpDeliveries?;
29
+ private readonly customEmailDeliveries?;
30
+ private readonly customSmsDeliveries?;
31
+ private readonly customMobilePushDeliveries?;
32
+ private readonly DEFAULT_MONTHLY_PUBLISHES;
33
+ private readonly DEFAULT_HTTP_DELIVERIES;
34
+ private readonly DEFAULT_EMAIL_DELIVERIES;
35
+ private readonly DEFAULT_SMS_DELIVERIES;
36
+ private readonly DEFAULT_MOBILE_PUSH_DELIVERIES;
37
+ private readonly FALLBACK_PUBLISH_PRICE_PER_MILLION;
38
+ private readonly FALLBACK_HTTP_DELIVERY_PRICE_PER_MILLION;
39
+ private readonly FALLBACK_EMAIL_DELIVERY_PRICE_PER_100K;
40
+ private readonly FALLBACK_SMS_PRICE_PER_MESSAGE;
41
+ private readonly FALLBACK_MOBILE_PUSH_PRICE_PER_MILLION;
42
+ private readonly FREE_TIER_PUBLISHES;
43
+ constructor(customMonthlyPublishes?: number | undefined, customHttpDeliveries?: number | undefined, customEmailDeliveries?: number | undefined, customSmsDeliveries?: number | undefined, customMobilePushDeliveries?: number | undefined);
44
+ supports(resourceType: string): boolean;
45
+ calculateCost(resource: ResourceWithId, region: string, pricingClient: PricingClient): Promise<MonthlyCost>;
46
+ private getPublishPrice;
47
+ private getHttpDeliveryPrice;
48
+ private getEmailDeliveryPrice;
49
+ private getSmsPrice;
50
+ private getMobilePushPrice;
51
+ private calculateCostBreakdown;
52
+ private buildAssumptions;
53
+ private hasCustomAssumptions;
54
+ }