I have an AWS Lambda function which I am trying to use to take video placed into an S3 bucket and transcode it. I need the transcoded file to be encrypted. The function works fine for straight transcoding but when I attempt to add the encryption portion it fails silently. There are no errors in the logs but no file is output either. Any help would be appreciated. Below is the code in question.
'use strict';
var AWS = require('aws-sdk');
var s3 = new AWS.S3({
apiVersion: '2012–09–25'
});
var eltr = new AWS.ElasticTranscoder({
apiVersion: '2012–09–25',
region: 'us-east-1'
});
exports.handler = function(event, context) {
console.log('Executing Elastic Transcoder Orchestrator');
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;
var pipelineId = 'PIPLINEID';
var split = key.split('.');
var nameandfolder = split[0];
var split2 = nameandfolder.split('/');
var name = split2[1];
console.log(bucket);
if (bucket !== 'project') {
context.fail('Incorrect Video Input Bucket');
return;
}
var params = {
PipelineId: pipelineId,
OutputKeyPrefix: 'Transcode_Output/',
Input: {
Key: key,
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto'
},
Outputs: [{
Key: name + '.mp4',
PresetId: 'PRESETID',
Encryption: {
Mode: 's3-aws-kms',
},
}]
};
console.log('Starting Job');
eltr.createJob(params, function(err, data){
if (err){
console.log(err);
} else {
console.log(data);
}
context.succeed('Job well done');
});
};