Hi! My name is Stephen and as a GIP Intern I worked in the DevOps team at HDE. My primary work during my internship involved using AWS Lambda functions. AWS Lambda are based upon the idea of ‘Serverless’ architecture. This means you don’t need to have an active server listening to requests, and you don’t to worry about maintaining any server. Lambda functions also make it very easy to scale to a large amount of users without worrying about changing code. While Lambda functions provide amazing features, deploying and managing them is very difficult. This is especially true when there is a 3rd party library in your code. This requires a difficult zip packaging process, which has to be done every time you change your code.
To make this process simpler, I investigated tools to automate the deployment and management of Lambda functions. I tried many different 3rd party frameworks, but the most comprehensive and full featured framework was the Serverless Framework. With just a few commands, you can have your lambda function deployed to AWS. With Serverless Framework, the complicated zip packaging process is no longer needed. The Serverless Framework provides detailed documentation for setup, configuration, and 3rd party plugins. It allows easy management of AWS infrastructure, and has an extensive 3rd party community. For example, updating Lambda code is as simple as running:
$ sls deploy
Managing infrastructure with Serverless Framework is as simple as writing 1 or 2 lines. Included with every Serverless application is a yml file. YML files are a popular format for continuous integration services such as Travis CI and Circle CI, and its just as easy to use with Serverless. With the Serverless Framework, you can add and manage infrastructure associated with AWS Lambda functions such as SNS triggers, API Gateway, and S3 buckets. As an example, you can add an SNS trigger to your Lambda function by writing the following in your YML file:
After running the command
sls deploy again, Serverless Framework will handle attaching this SNS trigger to your Lambda function automatically. This means you no longer have to navigate to the AWS console and manually add and create an SNS trigger. And then if you would like to remove this SNS trigger, it is as simple as removing that one line of code in the YML file. If you decide that you need to add API gateway to your Lambda function, Serverless makes that process very effortless. Just add the following code to your YML file:
Then again, run:
sls deploy. Serverless Framework will attach API Gateway to your Lambda function and display the URL associated with the API gateway. When you are done with the Lambda functions, it is very easy to remove your Lambda functions and the associated infrastructure, just run this command:
$ sls remove
After this command is run, you will see that the Lambda functions are now gone from AWS, and any SNS or API Gateway infrastructure is removed as well. I hope this brief introduction to the Serverless Framework encourages you start moving your application to Serverless architecture. If you would like a more in-depth look at Serverless Framework, please check out there website. Also, I wrote many instructions to deploy and manage Serverless applications. So please, check out my Gist!