Created
September 19, 2020 01:12
-
-
Save kylenstone/25f432f29eb3a75a25ece5afb88deed2 to your computer and use it in GitHub Desktop.
Frame.io Custom Action Backup to S3 Code: Lambda #1
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 { fetchAsset, invokeLambda } = require('./modules/api'); | |
exports.handler = async function (event, context) { | |
// Save the X-ray Trace ID and and this Lambda's function name. | |
// We'll pass them to our second 'file handler' Lambda. | |
const firstLambdaTraceID = process.env._X_AMZN_TRACE_ID; | |
const caller = context.functionName; | |
let id = JSON.parse(event.body).resource.id; | |
let { url, name} = await fetchAsset(id); | |
try { | |
await invokeLambda(caller, firstLambdaTraceID, url, name); | |
let returnPayload = { | |
statusCode: 202, | |
body: JSON.stringify({ | |
'title': 'Job received', | |
'description': `Your backup job for '${name}' has been triggered.`, | |
'traceID': `${firstLambdaTraceID}` | |
}) | |
}; | |
return returnPayload; | |
} catch(err) { | |
return (`Hit a problem: ${err.message}`); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment