UNPKG

@cloud-carbon-footprint/aws

Version:

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

25 lines 958 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCostFromCostExplorer = void 0; async function getCostFromCostExplorer(params, serviceWrapper) { const responses = await serviceWrapper.getCostAndUsageResponses(params); return responses .map((response) => { return response.ResultsByTime.map((result) => { const timestampString = result.TimePeriod.Start; return result.Groups.map((group) => { const amount = Number.parseFloat(group.Metrics.AmortizedCost.Amount); const currency = group.Metrics.AmortizedCost.Unit; return { amount, currency, timestamp: new Date(timestampString), }; }); }); }) .flat() .flat(); } exports.getCostFromCostExplorer = getCostFromCostExplorer; //# sourceMappingURL=CostMapper.js.map