How do I install Git using AWS Lambda?

2019-08-08 08:45发布

I have code in Code commit repository, I am writing a lambda function to build the code for every check-in (event) to the code commit repo.

I am not able to install git and hence cloning the repository is not happening.

How do I go about it.

1条回答
对你真心纯属浪费
2楼-- · 2019-08-08 08:56

As the others have mentioned installing git on lambda is either really hard or totally impossible. I did a session at reinvent about lambda and step functions and spent some time trying to get it to work. I gave up. An alternative I found more recently is to use one of the git libraries for node or python or whatever language you are using. But this is still a bad idea and will cause pain when you need to maintain the function.

It turns out another alternative is here but looks messy: Running 'git' in AWS lambda

Using CodeBuild is a much better idea. Its a build system on AWS that will do anything you want it to. Uses Docker and you can supply your own docker image. I did a multi-stage build to create the smallest possible GatsbyJS image. Now the downside is that it takes 30 seconds to provision (it took closer to 2 minutes without the custom image). Plus CodeBuild has 100 free minutes per month, every month for ever. If this is a personal scenario, this could cover you completely.

If you don’t mind mixing the clouds, also look into Google’s Cloud Container Builder. It says its for building docker images, but you can use it for anything you need. And the first 120 minutes EVERY day are free. So definitely a cool service to look into. There is nothing stopping you from mixing services from different clouds.

My session at reInvent used codebuild, lambda and a lot of other services to live blog the session using images from a raspberry pi and a service to recognize which slide was being shown. It worked beautifully. Do a google search for SRV335 and you should find it if you are interested in seeing codebuild with lambda in action

查看更多
登录 后发表回答