I am calling the AWS Transcribe service from a Lambda
Lambda code:
module.exports.createTranscribeJob = (event, context, callback) => {
const region = event.Records[0].awsRegion;
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
const transcribeservice = new AWS.TranscribeService({apiVersion: '2017-10-26'});
// Set the transcribeservice startTranscriptionJob params
const params = {
LanguageCode: 'en-US',
Media: {
MediaFileUri: `https://s3-${region}.amazonaws.com/${bucket}/${key}`
},
MediaFormat: 'mp3',
TranscriptionJobName: key,
MediaSampleRateHertz: 0,
OutputBucketName: bucket
};
// call startTranscriptionJob with the params
transcribeservice.startTranscriptionJob(params, function(err, data) {
if (err){
console.log(err, err.stack);
} else {
console.log(data);
}
});
callback(null);
};
I set the version of the API I want to use new AWS.TranscribeService({apiVersion: '2017-10-26'})
When I call transcribeservice.startTranscriptionJob
the job fails with this error:
{ UnexpectedParameter: Unexpected key 'OutputBucketName' found in params
at ParamValidator.fail (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:50:37)
at ParamValidator.validateStructure (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:77:14)
at ParamValidator.validateMember (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:88:21)
at ParamValidator.validate (/var/runtime/node_modules/aws-sdk/lib/param_validator.js:34:10)
at Request.VALIDATE_PARAMETERS (/var/runtime/node_modules/aws-sdk/lib/event_listeners.js:125:42)
at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at callNextListener (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:95:12)
at /var/runtime/node_modules/aws-sdk/lib/event_listeners.js:85:9
at finish (/var/runtime/node_modules/aws-sdk/lib/config.js:320:7)
at /var/runtime/node_modules/aws-sdk/lib/config.js:338:9
message: 'Unexpected key \'OutputBucketName\' found in params',
code: 'UnexpectedParameter',
time: 2018-07-19T12:50:58.278Z }
If I remove OutputBucketName: bucket
it works, so I know its not a permissions issue
Looking at the Source code for AWS Javascript sdk OutputBucketName
is defined as a member of StartTranscriptionJobRequest
https://github.com/aws/aws-sdk-js/blob/75978fcfe4186d5a310e9b5c6d6328e90997edf0/apis/transcribe-2017-10-26.normal.json#L491
My only guess is lambda is not using the correct SDK even though I state the API version.
Any help is appreciated, please let me know if I have an error on my side.
Thanks
The problem is AWS Lambda does not use the latest JS SDK
The solution is to include the latest JS SDK in your own node_module folder
npm install aws-sdk
Then your lambda code will use the latest version of the SDK