0

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');
 });
};
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Not sure this makes a difference, but the docs indicate that the encryption mode is S3-AWS-KMS rather than s3-aws-kms. – jarmod May 18 '17 at 21:44
  • Thank you for your suggestion @jarmod. When I try that I get a validation error that seems to indicate it should be lower case instead. `validation error detected: Value 'S3-AWS-KMS' at 'output.encryption.mode' failed to satisfy constraint: Member must satisfy regular expression pattern: (^s3$)|(^s3-aws-kms$)|(^aes-cbc-pkcs7$)|(^aes-ctr$)|(^aes-gcm$)` – Colstar May 19 '17 at 13:23
  • Good to know, thanks. That document is misleading. – jarmod May 19 '17 at 14:30

0 Answers0