
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!