Skip to content

Instantly share code, notes, and snippets.

@benclmnt
Last active March 20, 2024 05:32
Show Gist options
  • Save benclmnt/ed4c9a4c81e841753b056377f27e03e6 to your computer and use it in GitHub Desktop.
Save benclmnt/ed4c9a4c81e841753b056377f27e03e6 to your computer and use it in GitHub Desktop.
Get EC2 name to instance_id mapping from AWS console
// start from the last page and update the # of pages below
let pages = 100;
let s = `name,instance_id,instance_type\n`;
for (let i = 0; i < pages; i++) {
document.querySelectorAll('tr[data-selection-item="item"]').forEach(x => {
let name = x.querySelectorAll('td')[1].textContent;
let instanceID = x.querySelectorAll('td')[2].textContent;
let instanceType = x.querySelectorAll('td')[4].textContent;
s += `${name},${instanceID},${instanceType}\n`
});
document.querySelector('button[aria-label="Previous page"]').click();
await new Promise(resolve => setTimeout(resolve, 100));
};
console.log(s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment