aws-amicleaner 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +9 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -47,21 +47,20 @@ async function run({
47
47
  return autoscaling[region];
48
48
  };
49
49
 
50
- let amis = [];
51
-
52
50
  const regions = await fetchRegions(ec2Client('us-east-1'), rawRegions);
53
- for (const region of regions) {
54
- let regionalAMIs = await fetchAMIs(now, ec2Client(region), autoscalingClient(region), includeName, includeTagKey, includeTagValue, excludeNewest, excludeInUse, excludeDays);
55
- regionalAMIs = regionalAMIs.map(ami => ({
56
- region,
57
- ...ami
58
- }));
59
- amis = [...amis, ...regionalAMIs];
60
- }
51
+ const amisPerRegion = await Promise.all([...regions].map(region =>
52
+ fetchAMIs(now, ec2Client(region), autoscalingClient(region), includeName, includeTagKey, includeTagValue, excludeNewest, excludeInUse, excludeDays)
53
+ .then(amis => amis.map(ami => ({
54
+ region,
55
+ ...ami
56
+ })))
57
+ ));
58
+ let amis = amisPerRegion.flat();
61
59
 
62
60
  if (verbose === true) {
63
61
  const pt = new PrettyTable();
64
62
  pt.sortTable('Name');
63
+ pt.sortTable('Region');
65
64
  pt.create(['Region', 'ID', 'Name', 'Creation Date', 'Delete?', 'Include reasons', 'Exclude reasons'], amis.map(ami => [
66
65
  ami.region,
67
66
  ami.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-amicleaner",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "To clean up your AWS AMIs: First, include AMIs by name or tag. Second, exclude AMIs in use, younger than N days, or the newest N images. Third, manually confirm the list of AMIs for deletion.",
5
5
  "main": "index.js",
6
6
  "bin": "index.js",