You can return to the original look by selecting English in the language selector
above.

Building a Continuous Delivery Pipeline for a Lambda Application with
AWS CodePipeline

You can use AWS CodePipeline to create a continuous delivery pipeline for your Lambda
application. CodePipeline combines source
control, build, and deployment resources to create a pipeline that runs whenever you
make a change to your
application's source code.

In this tutorial, you create the following resources.

Repository – A Git repository in AWS CodeCommit. When you push a change,
the pipeline copies the source code into an Amazon S3 bucket and passes it to the
build project.

Build project – An AWS CodeBuild build that gets the source code from
the pipeline and packages the application. The source includes a build specification
with commands that install
dependencies and prepare an AWS Serverless Application Model (AWS SAM) template for
deployment.

Deployment configuration – The pipeline's deployment stage defines a
set of actions that take the AWS SAM template from the build output, create a change
set in AWS CloudFormation, and execute
the change set to update the application's AWS CloudFormation stack.

AWS CloudFormation stack – The deployment stage uses a template to create a stack
in AWS CloudFormation. The template is a YAML-formatted document that defines the
resources of the Lambda application. The
application includes a Lambda function and an Amazon API Gateway API that invokes
it.

Roles – The pipeline, build, and deployment each have a service role
that allows them to manage AWS resources. The console creates the pipeline and build
roles when you create
those resources. You create the role that allows AWS CloudFormation to manage the
application stack.

The pipeline maps a single branch in a repository to a single AWS CloudFormation stack.
You can create additional pipelines
to add environments for other branches in the same repository. You can also add stages
to your pipeline for testing,
staging, and manual approvals. For more information about AWS CodePipeline, see What is AWS CodePipeline.

Prerequisites

This tutorial assumes that you have some knowledge of basic Lambda operations and
the Lambda console. If you
haven't already, follow the instructions in Getting Started with AWS Lambda to create your first Lambda function.

To follow the procedures in this guide, you will need a command line terminal or shell
to run commands. Commands are shown in
listings preceded by a
prompt symbol ($) and the name of the current directory, when appropriate:

~/lambda-project$ this is a command
this is output

For long commands, an escape character (\) is used to split a command over multiple lines.

During the build phase, the build script uploads artifacts to Amazon Simple Storage
Service (Amazon S3). You can use an existing bucket,
or create a new bucket for the pipeline. Use the AWS CLI to create a bucket.

$ aws s3 mb s3://lambda-deployment-artifacts-123456789012

Create an AWS CloudFormation Role

Create a role that gives AWS CloudFormation permission to access AWS resources.

Create a Pipeline

Create a pipeline that deploys your application. The pipeline monitors your repository
for changes, runs an
AWS CodeBuild build to create a deployment package, and deploys the application with
AWS CloudFormation. During the pipeline
creation process, you also create the AWS CodeBuild build project.

Complete the Deployment Stage

The deployment stage has an action that creates a change set for the AWS CloudFormation
stack that manages your Lambda
application. A change set specifies the changes that are made to the stack, such as
adding new resources and
updating existing resources. Change sets let you preview the changes that are made
before making them, and add
approval stages. Add a second action that executes the change set to complete the
deployment.