Created
September 24, 2019 14:18
-
-
Save johndstein/b6ac0b3b31406cfb66c32ce6fa99df49 to your computer and use it in GitHub Desktop.
Lambda for listing s3 files
This file contains 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 AWS = require('aws-sdk') | |
if (process.env.AWS_PROFILE) { // eslint-disable-line | |
AWS.config.credentials = new AWS.SharedIniFileCredentials({ | |
profile: process.env.AWS_PROFILE // eslint-disable-line | |
}) | |
AWS.config.logger = console | |
} | |
const s3 = new AWS.S3({ apiVersion: '2006-03-01' }) | |
exports.handler = async(event, context) => { | |
const objects = await s3.listObjects(event).promise(); | |
return objects.Contents.map((o) => o.Key) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment