Last active
March 20, 2024 05:32
-
-
Save benclmnt/ed4c9a4c81e841753b056377f27e03e6 to your computer and use it in GitHub Desktop.
Get EC2 name to instance_id mapping from AWS console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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