Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
truncate create-s3-index-html output (#190)
Browse files Browse the repository at this point in the history
Example output:

```
{
  "Location": "https://cloudfront.amazonaws.com/2017-03-25/distribution/E35YBTV6QCR5BA/invalidation/IPMMYLLQ42EF2",
  "Invalidation": {
    "Id": "IPMMYLLQ42EF2",
    "Status": "InProgress",
    "CreateTime": "2019-08-01T21:48:07.496Z",
    "InvalidationBatch": {
      "Paths": {
        "Quantity": 898,
        "Items": [
          "/ubuntu/dists/cosmic-4.16/main/source/",
          "/ubuntu/pool/main/h/hhvm-dev/",
          "/ubuntu/dists/cosmic-4.7/main/binary-amd64/",
          "/old/resources/hdf/",
          "/ubuntu/dists/xenial-lts-3.21/main/binary-i386/",
          "/ubuntu/dists/disco-4.4/main/",
          "/debian/dists/stretch-4.16/main/binary-i386/",
          "/ubuntu/dists/trusty-4.7/main/binary-i386/",
          "-- truncated --",
          "/old/mint/",
          "/ubuntu/dists/bionic-4.3/main/binary-amd64/",
          "/ubuntu/dists/precise-lts-3.3/main/binary-i386/",
          "/ubuntu/dists/xenial-4.6/main/binary-i386/",
          "/ubuntu/dists/cosmic-4.11/main/source/",
          "/ubuntu/dists/cosmic-4.12/main/source/",
          "/ubuntu/dists/trusty-4.9/main/binary-amd64/",
          "/old/resources/conf/2013/"
        ]
      },
      "CallerReference": "s3-index-update-2019-08-01T21:48:06.799Z"
    }
  }
}
```
  • Loading branch information
jjergus authored Aug 1, 2019
1 parent e0b974e commit 9389fcb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions aws/lambdas/create-s3-index-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function handle_s3_response(err, data, event, callback, acc) {
);
return;
}

publish_indices(event, acc, callback);
}

Expand Down Expand Up @@ -74,7 +74,19 @@ function publish_indices(event, objs, callback) {
}
}
},
(err, data) => callback(err, data)
(err, data) => {
try {
const paths = data.Invalidation.InvalidationBatch.Paths.Items;
if (paths.length > 17) {
data.Invalidation.InvalidationBatch.Paths.Items = [
...paths.slice(0, 8),
'-- truncated --',
...paths.slice(-8),
];
}
} catch (e) {}
callback(err, data);
}
);
}).catch(err => callback(err));
}
Expand Down Expand Up @@ -151,7 +163,7 @@ exports.handler = (event, context, callback) => {
callback('bucket must be specified');
return;
}

const s3 = new AWS.S3();
s3.listObjectsV2(
{ Bucket: event.bucket },
Expand Down

0 comments on commit 9389fcb

Please sign in to comment.