Created
February 28, 2019 12:09
-
-
Save christianhaller3000/1d71383b44477ac802329af910a87db5 to your computer and use it in GitHub Desktop.
check ec2
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
const { EC2 } = require("aws-sdk"); | |
const region = "eu-central-1"; | |
module.exports = async () => { | |
const ec2 = new EC2({ | |
region | |
}); | |
const { Regions } = await ec2.describeRegions().promise(); | |
Regions.map(async (r) => { | |
const { Reservations } = await new EC2({ | |
region: r.RegionName | |
}) | |
.describeInstances() | |
.promise(); | |
return Reservations.map((reservation) => | |
reservation.Instances.map((instance) => { | |
const { Value: name } = instance.Tags.find((tag) => tag.Key === "Name"); | |
console.log(`${name}: ${instance.LaunchTime}`); | |
return instance; | |
}) | |
); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment