Last active
May 15, 2019 00:41
-
-
Save jsmithdev/a67df6120bb39781a3dd350b09b5dbf6 to your computer and use it in GitHub Desktop.
lambda-s3-trigger.js - to be triggered off an S3 CRED action like create. Set env var HOSTNAME to the hostname of where you want to send the file's metadata when action occurs.
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 hostname = process.env.HOSTNAME | |
const https = require('https') | |
exports.handler = (event, context, callback) => { | |
const data = JSON.stringify({ records: event.Records }) | |
const opts = { | |
hostname, | |
method: 'POST', | |
path: '/aws-door', | |
headers: { | |
'Content-Type': 'application/json', | |
'Content-Length': Buffer.byteLength(data) | |
} | |
} | |
const req = https.request(opts, (res) => { | |
console.log(`statusCode: ${res.statusCode}`) | |
res.on('data', (d) => { | |
process.stdout.write(d) | |
}) | |
}) | |
req.on('error', console.log) | |
req.write(data) | |
req.end() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment