Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source Control and deployment for AWS Lambda

Has anybody come up with a good solution to source control and deploy code to AWS Lambda? I really hate that I have to zip the files all the time and upload them. Is there a better way to do this perhaps a service that pushes code based on changes to Lambda?

like image 218
ecorvo Avatar asked Jul 28 '15 18:07

ecorvo


People also ask

How AWS Lambda is deployed?

To deploy your function's code, you upload the deployment package from Amazon Simple Storage Service (Amazon S3) or your local machine. You can upload a . zip file as your deployment package using the Lambda console, AWS Command Line Interface (AWS CLI), or to an Amazon Simple Storage Service (Amazon S3) bucket.

What are the three different ways you can deploy your code to Lambda?

Summary. There are three common ways to edit Lambda functions: in the Lambda console, Cloud 9, and locally. There are advantages and disadvantages of all three methods, but personally I think the best choice is to write the function locally and deploy it using a deployment script.


2 Answers

You can try Serverless Framework for this. Current beta looks very promising.

Serverless Framework allow you to build entire application without any servers. It combines AWS API Gateway with AWS Lambda functions and supports auto-deployment.

Beta v1 release supports NodeJS only, but they plan to support for all languages.

Project Docs: http://docs.serverless.com/v0.5.0/docs

like image 164
countTheRow Avatar answered Oct 23 '22 04:10

countTheRow


#!/bin/bash cd /your/workspace  #zips up the new code zip -FSr yourzipfile.zip . -x *.git* *bin/\* *.zip  #Updates function code of lambda and pushes new zip file to s3bucket for cloudformation lambda:codeuri source aws lambda update-function-code --function-name  arn:aws:lambda:us-west-2:YOURID:function:YOURFUNCTIONNAME --zip-file fileb://yourzipfile.zip aws s3 cp yourzipfile.zip s3://yourbucketname/yourzipfile.zip 

Depends on aws-cli install and aws profile setup

aws --profile yourProfileName configure 

And my rant: I wish cloudformation lambda:codeuri would accept any url not just s3://bucketname/filename... so I could point it straight to github.

like image 40
Eric Nord Avatar answered Oct 23 '22 03:10

Eric Nord