AWS CostExplorer API

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ce:*"
],
"Resource": [
"*"
]
}
]
}
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>AWS Usage</title><script src="aws-sdk-2.356.0.min.js"></script><script src="moment.js"></script></head><body><div>Sample Test with AWS JS SDK</div><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script><script>$(document).ready(function () {console.log(' we are ready! ');AWS.config.update({    accessKeyId: '<your_access_key>',    secretAccessKey: '<your_secret_key>',    apiVersion: '2017-10-25',    region: 'us-east-1'});const costexplorer = new AWS.CostExplorer();console.log(costexplorer);var date = new Date();var StartDate = moment().startOf('month').format('YYYY-MM-DD');var EndDate = moment(date).add(1,'d').format('YYYY-MM-DD');console.log('StartDate ' + StartDate);console.log('EndDate ' + EndDate);var costParams = {    TimePeriod: {        End: EndDate,         Start: StartDate    },    Granularity: 'DAILY',    Metrics: ['BlendedCost']}console.log(costParams);costexplorer.getCostAndUsage(costParams, function (err, data) {    if (err) {        console.log(err); // an error occurred    }    else {        console.log(data);    }});});</script></body></html>

Maninder Mandy Singh

Written by

CTO at Votigo, Inc (www.votigo.com) | Heyo ( www.heyo.com ) tech freak, seinfeld lover :)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade