Automate Build & Deployment of an AWS SAM Application using AWS CodeBuild & CodePipeline

This article shows you how to set up a fully-automated CI/CD pipeline for your AWS SAM application.

Step 1 β€” Create SAM App

Create a SAM application as described here. Push this code to a CodeCommit repo.

Step 2 β€” Add Build Spec

Add the following to the root directory of the Git repo in a new file named buildspec.yml:

version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: 12
    commands:
    - npm install
    - aws cloudformation package --template-file template.yaml --s3-bucket my-s3-bucket --output-template-file cft.yaml
artifacts:
  type: zip
  files:
  - cft.yaml
  discard-paths: yes

Step 3 β€” Create Pipeline

Create a CodePipeline as shown below:

Now, whenever you push code to the repo, it’ll get auto-deployed to Lambda!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.