Skip to content

Instantly share code, notes, and snippets.

@jmorvan
Created March 10, 2021 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmorvan/66b1beae106c84cd30c041f9daa80599 to your computer and use it in GitHub Desktop.
Save jmorvan/66b1beae106c84cd30c041f9daa80599 to your computer and use it in GitHub Desktop.
Amazon AWS dowload all invoices for selected period
//USE TO DOWNLOAD ALL INVOICES DISPLAYED ON SCREEN IN THE AWS CONSOLE BILLING SECTION
let jQ = window.jQuery
let downloadLink = invoiceName => `https://console.aws.amazon.com/billing/rest/v1.0/bill/invoice/download?invoicenumber=${invoiceName}&invoiceGroupId=${invoiceName}`
let downloadURL = function downloadURL(url, id){
const hiddenIFrameID = 'hiddenDownloader' + id
const iframe = document.createElement('iframe')
iframe.id = hiddenIFrameID
iframe.style.display = 'none'
document.body.appendChild(iframe)
iframe.src = url
}
function dlInvoices(){
let entries = jQ('.col1 a');
entries.each((i,y)=> {
downloadURL(downloadLink(y.text.trim()), i)
});
}
jQ('.payment-history-section div.right').prepend('<a href="javascript:dlInvoices()">DOWNLOAD ALL DISPLAYED INVOICES</a>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment