Created
July 2, 2020 12:03
-
-
Save jflasher/3a1e4310012639d66f3e45e698360725 to your computer and use it in GitHub Desktop.
Lambda function to make an S3 Invetory object publicly accessible
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
console.log('Loading function'); | |
const aws = require('aws-sdk'); | |
const s3 = new aws.S3({ apiVersion: '2006-03-01' }); | |
exports.handler = (event, context, callback) => { | |
// Get the object from the event and show its content type | |
const bucket = event.Records[0].s3.bucket.name; | |
const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' ')); | |
const params = { | |
Bucket: bucket, | |
Key: key, | |
GrantRead: "uri=http://acs.amazonaws.com/groups/global/AllUsers" | |
}; | |
s3.putObjectAcl(params, (err, data) => { | |
return callback(err); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment