The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

38786 (7) [Avatar] Offline
I had trouble deploying the updated transcode_video lambda function. It kept timing out from the command line. The zip file for deployment is Just over 30 MB. I ended up manually uploading from the lambda aws console. Its a little unclear in the UI how to do that: In the Function Code section of the Lambda AWS console there is a button to upload a function package, clicking it will let you select your zip file, but after that nothing seems to happen. You have to click the save button at the top of the page, then it will upload and make the change. You should see a message saying its saving near the top of the page, it will go away once the upload and save is complete (takes 15-30 seconds).

Once you get the function uploaded and you run it you'll be happy to find out that it doesn't work. Firebase denies access to the key entry. You have a couple of options here. You can change the .write firebase rule to "true" like you did for .read in listing 9.3. This will let the transcode-video lambda function connect, but it will also let anyone connect with no authentication.

The reason this doesn't work is the call to firebase.initializeApp() just passes in the name of the json file (as process.env.SERVICE_ACCOUNT). Firebase needs the contents of that json file. I'd post an example, but I haven't reverse engineered it yet and Google in their infinite wisdom have the initializeApp() function take an options object but they don't bother to document what the hell the options are. There are some examples out there, but I haven't managed to piece all of the right bits together to get the fields named the right thing and for this to actually authenticate. I'm ready to move on and skip this bit, I don't feel like wasting anymore time on what has already been a very "figure it out yourself" book which really is defeating the purpose of the book in the first place.

Hopefully this will help save someone some time / frustration.
38786 (7) [Avatar] Offline
Ok, I dug some more and found that you can authenticate a service worker in a manner that is very similar to what was shown in the book. - scroll down a bit and click on the node.js tab for some sample code. I don't know if this is "cheating" by using the admin functionality as they supposedly have rights to read or write anything. I decided to try it out because of the similarity to what was shown in the book. You will need to add firebase-admin to your package.json file and do an npm install or just run "npm install firebase-admin --save"

Below is the top of my index.js file, only a few lines have changed

var AWS = require('aws-sdk');
//var firebase = require('firebase');
var firebase = require("firebase-admin");
var firebaseSettings = require('./' + process.env.SERVICE_ACCOUNT);

var elasticTranscoder = new AWS.ElasticTranscoder({
    region: process.env.ELASTIC_TRANSCODER_REGION

var dbURL = process.env.DATABASE_URL;
	credential: firebase.credential.cert(firebaseSettings),
	databaseURL: dbURL

function pushVideoEntryToFirebase(key, callback) {

Recreate the zip package (now almost 50MB) and deploy to Lambda. This should allow you to write to firebase without having the .write permission set to true so at least some form of authentication is happening. As you can see in the code I commented out the require statement for firebase, I could have cleaned out my node_modules folder and that would result in a smaller deployment size, but at this point I was too annoyed and I wasn't 100% confident I wasn't going to need it.

Hope this helps.

480416 (10) [Avatar] Offline
Hello! Could you be referring to a different product? This forum is for one of Manning's Serverless video courses, but it sounds like you may be commenting on one of our books?
38786 (7) [Avatar] Offline
480416 wrote:Hello! Could you be referring to a different product? This forum is for one of Manning's Serverless video courses, but it sounds like you may be commenting on one of our books?

You are correct, this was intended for the book forum. I tried to delete the posts, but it won't let me. I've reposted on the book forum.