Continuous Delivery - Serverless Architectures with AWS Lambda

Continuous Delivery

We recommend that you programmatically manage all of your serverless deployments through CI/CD pipelines. This is because the speed with which you will be able to develop new features and push code changes with Lambda will allow you to deploy much more frequently. Manual deployments, combined with a need to deploy more frequently, often result in both the manual process becoming a bottleneck and prone to error.

The capabilities provided by AWS CodeCommit, AWS CodePipeline, AWS CodeBuild, AWS SAM, and AWS CodeStar provide a set of capabilities that you can natively combine into a holistic and automated serverless CI/CD pipeline (where the pipeline itself also has no infrastructure that you need to manage).

Here is how each of these services plays a role in a well-defined continuous delivery strategy.

AWS CodeCommit– Provides hosted private Git repositories that will enable you to host your serverless source code, create a branching strategy that meets our recommendations (including fine-grained access control), and integrate with AWS CodePipeline to trigger a new pipeline execution when a new commit occurs in your release branch.

AWS CodePipeline – Defines the steps in your pipeline. Typically an AWS CodePipeline pipeline begins where your source code changes arrive. Then you execute a build phase, execute tests against your new build, and perform a deployment and release of your build into the live environment. AWS CodePipeline provides native integration options for each of these phases with other AWS services.

AWS CodeBuild – Can be used for the build state of your pipeline. Use it to build your code, execute unit tests, and create a new Lambda code package. Then, integrate with AWS SAM to push your code package to Amazon S3 and push the new package to Lambda via AWS CloudFormation.

After your new version is published to your Lambda function through AWS CodeBuild, you can automate your subsequent steps in your AWS CodePipeline pipeline by creating deployment-centric Lambda functions. They will own the logic for performing integration tests, updating function aliases, determining if immediate rollbacks are necessary, and any other application-centric steps needed to occur during a deployment for your application (like cache flushes, notification messages, etc.). Each one of these deployment-centric Lambda functions can be invoked in sequence as a step within your AWS CodePipeline pipeline using the Invoke action. For details on using Lambda within AWS CodePipeline, see this documentation.

In the end, each application and organization has its own requirements for moving source code from repository to production. The more automation you can introduce into this process, the more agility you can achieve using Lambda.

AWS CodeStar – A unified user interface for creating a serverless application (and other types of applications) that helps you follow these best practices from the beginning. When you create a new project in AWS CodeStar, you automatically begin with a fully implemented and integrated continuous delivery toolchain (using AWS CodeCommit, AWS CodePipeline, and AWS CodeBuild services mentioned earlier). You will also have a place where you can manage all aspects of the SDLC for your project, including team member management, issue tracking, development, deployment, and operations. For more information about AWS CodeStar, go here.