UNPKG

@cloud-carbon-footprint/aws

Version:

The core logic to get cloud usage data and estimate energy and carbon emissions from Amazon Web Services.

34 lines 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const common_1 = require("@cloud-carbon-footprint/common"); const AWSInstanceTypes_1 = require("../../AWSInstanceTypes"); const domain_1 = require("../../../domain"); class ComputeOptimizerRecommendation { constructor(init) { this.accountId = init.accountId; this.accountName = this.accountId; this.type = init.finding; } getRegion(resourceArn) { return resourceArn.split(':')[3]; } getResourceId(resourceArn) { return resourceArn.split('/').pop(); } getVCpuHours(vcpus, instanceType) { if ((0, common_1.containsAny)(Object.keys(AWSInstanceTypes_1.BURSTABLE_INSTANCE_BASELINE_UTILIZATION), instanceType)) { return (((parseFloat(vcpus) * AWSInstanceTypes_1.BURSTABLE_INSTANCE_BASELINE_UTILIZATION[instanceType]) / domain_1.AWS_CLOUD_CONSTANTS.AVG_CPU_UTILIZATION_2020) * (0, common_1.getHoursInMonth)()); } return parseFloat(vcpus) * (0, common_1.getHoursInMonth)(); } getOptimalRecommendation(recommendationOptions) { const optimalPerformanceRiskLevel = 3; return recommendationOptions.find((recommendation) => parseFloat(recommendation.performanceRisk) <= optimalPerformanceRiskLevel); } } exports.default = ComputeOptimizerRecommendation; //# sourceMappingURL=ComputeOptimizerRecommendation.js.map