Skip to content

Instantly share code, notes, and snippets.

@christianhaller3000
Created February 28, 2019 12:09
Show Gist options
  • Save christianhaller3000/1d71383b44477ac802329af910a87db5 to your computer and use it in GitHub Desktop.
Save christianhaller3000/1d71383b44477ac802329af910a87db5 to your computer and use it in GitHub Desktop.
check ec2
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