aws-cost-explorer icon indicating copy to clipboard operation
aws-cost-explorer copied to clipboard

is cost by service available?

Open sanat1772 opened this issue 4 years ago • 1 comments

sanat1772 avatar Jul 14 '20 06:07 sanat1772

Yes, try this:

var config = { 
    apiVersion: '2017-10-25',
    accessKeyId : 'PUT_YOUR_KEY',
    secretAccessKey : 'PUT_YOUR_SECRET',
    region : 'us-east-1'
}

var CostExplorer = require('aws-cost-explorer');
var ce = CostExplorer(config);

var opts = {
    granularity : "MONTHLY",
    metrics : "BlendedCost" ,
    groupBy : [
        {
        "Type":"DIMENSION",
        "Key":"SERVICE"
        }
    ]
}

ce.getMonthToDateCosts(opts, function(err, data) {
    if (err) {
        console.log(err);
    } else {
        console.dir(data, { depth: null });
    }
});

dnavarrom avatar Jul 16 '20 20:07 dnavarrom