Dustin Coates in Alexa

Speed Up Your Alexa Skill Deployment to Lambda

One of the unfortunate hassles of working with Alexa Skills is the time loop between making and a change and being able to test it out. Although there are plenty of testing solutions available, often you want to interact with it on your Alexa device. Most of you will be using AWS Lambda and will be well-experienced with making a small change to a single JavaScript file locally, but being unable reflect that in Lambda without uploading everything again. Unfortunately, I don’t have a trick to do that, but I do have a couple hints on speeding up the deploy process.

Using ASK CLI

If you’re using ASK CLI, you’re using $ ask deploy to get your code up on Lambda. Using that command every time, though, will significantly increase your time waiting for deployment. The deploy command doesn’t just deploy the code to Lambda, but also sends changes to the skill and the interaction model. If you’ve only changed the fulfillment, skip the unnecessary steps and target just Lambda with the -t flag: $ ask deploy -t lambda.

Reducing node_modules directory size

The primary problem for skill deployment is the node_modules directory. This directory rarely changes, but comes along for the ride on every deploy anyway. Reducing the size of this directory will have the biggest impact on your deployment time.

Two projects can help. The first is node-prune by TJ Holowaychuk. It removes unnecessary files from module directories, like README files. The modclean project takes this even further, adding directories to the cruft it removes. Directories including tests or examples are taken away, leaving you with a much smaller node_modules directory to deploy.