Search code examples
amazon-web-servicesaws-lambdaamazon-ecs

build and push docker image to AWS ECR using lambda


Is it possible to automate building a docker image from code committed into github (no tests involved) and then push it to AWS ECR using a lambda function?


Solution

  • you cannot do it just with lambda as lambda is not really a suitable execution environment for the docker daemon (necessary to build the images), however you can use lambda + sns to trigger an endpoint that could point to a service you developed, hosted on ec2 that would trigger the docker build command after a git clone (you can use something similar to python's fabfile.org or a framework that allows you to execute server commands).

    You sure can extend this idea on perhaps bringing the ec2 build machine up with some ami that automates this, etc....

    The big point here is that you don't really have control over what's provisioned in lambda, so you need ec2.