How To Deploy Serverless SAM Using Code Pipeline (5 Min) | Using AWS Code Build & Code Commit
Summary
TLDRABI from gokjdb guides viewers through deploying a serverless AWS SAM application using AWS CodeBuild and AWS CodePipeline. The tutorial covers creating a repository, setting up a serverless project with the Python runtime, configuring and deploying the application, and verifying deployment through an API Gateway URL. It also explains creating a buildspec.yml file, setting permissions for the service role, and automating the deployment process with a pipeline that responds to code changes, culminating in a demonstration of updating the application and redeploying.
Takeaways
- 📝 Start by creating a repository in AWS Code Commit and cloning it locally.
- 🛠️ Use the AWS SAM (Serverless Application Model) CLI to create a new serverless project with Python as the runtime.
- 🔄 Choose 'Create from existing sources' and allow time for project files to be generated.
- ⚙️ Configure the project using the 'hello world' template and run it to ensure it works.
- 🚀 Execute 'sam build' and 'sam deploy --guided' to deploy the application and follow the prompts for configuration.
- 🔗 After deployment, check the logs for the API Gateway endpoint URL and verify the application by accessing it.
- 📄 Create a 'buildspec.yml' file necessary for deploying the application with AWS CodeDeploy.
- 🔄 Commit and push all project files to the Code Commit repository.
- 🏗️ Set up a build project in AWS CodeBuild, specifying the source, branch, and operating system.
- 👮♂️ Add necessary permissions to the service role for access to AWS services like S3, CloudWatch, API Gateway, CloudFormation, and Lambda.
- 🔄 Initiate the build process and monitor the logs for success or errors.
- 🔄 Create a pipeline in AWS CodePipeline, linking it to the source and build projects.
- 🔄 Make changes to the application, commit, and push to trigger the pipeline's automated build and deployment process.
- 🔄 Monitor the pipeline and build logs to confirm successful deployment of changes.
Q & A
What is the main topic of the video?
-The main topic of the video is how to deploy a serverless AWS SAM (Serverless Application Model) application using AWS CodeBuild and AWS CodePipeline.
What is the first step mentioned in the script for deploying a serverless application?
-The first step is to navigate to the CodeCommit service, create a new repository, and clone it to the local machine using 'git clone'.
Which tool is used to create a new AWS serverless project?
-The tool used to create a new AWS serverless project is the AWS SAM CLI (Command Line Interface).
What runtime is chosen for the serverless project in the video?
-Python is chosen as the runtime for the serverless project.
What template is selected in the configuration for the SAM application?
-The 'Hello World' template is selected as the input for the SAM application configuration.
What command is used to build the SAM application in the terminal?
-The command used to build the SAM application is 'sam build'.
What does 'Sam deploy --guided' do in the script?
-'Sam deploy --guided' is used to follow the prompts and set the configuration for the SAM deployment.
What file is created for deploying the application using CodeDeploy?
-A 'buildspec.yml' file is created, which is needed when deploying the application using CodeDeploy.
What service role is mentioned in the script, and why is it important?
-The service role mentioned is important because it needs to have permissions to access AWS services like S3, CloudWatch, API Gateway, CloudFormation, and Lambda for the deployment process.
What is the purpose of creating an AWS CodePipeline?
-The purpose of creating an AWS CodePipeline is to automate the deployment process by integrating source control, build, and deployment stages.
How does the video script demonstrate updating the application?
-The script demonstrates updating the application by editing the 'app.py' file, changing the output message, committing the change, and pushing it to the remote master branch to trigger a new pipeline execution.
Outlines
🚀 Deploying Serverless SAM Application
This paragraph outlines the process of deploying a serverless AWS SAM application using AWS CodeBuild and AWS CodePipeline. It begins with creating a repository in the Code Commit service, cloning it, and setting up a new AWS serverless project with Python as the runtime. The video demonstrates running the project, building it with SAM, and deploying it with guided prompts, resulting in an API Gateway endpoint. The paragraph concludes with the successful deployment, as indicated by a 'hello world' message, and the creation of a buildspec.yml file for future CodeDeploy usage.
🔄 Automating Deployment with CodePipeline
In this paragraph, the focus shifts to automating the deployment process using AWS CodePipeline. It starts with committing and pushing project files to the Code Commit repository, followed by creating a build project in AWS CodeBuild, specifying the source, branch, and operating system. The paragraph details the setup of permissions for the service role to access necessary AWS services. The build process is initiated, and the viewer is guided to monitor the build logs for success. The paragraph also covers the creation of a CodePipeline, configuring its stages, and observing the pipeline's automatic execution upon code changes. The summary ends with the viewer being prompted to check the updated API endpoint after a change is made to the app.py file, signifying a successful automated deployment cycle.
Mindmap
Keywords
💡Serverless
💡AWS CodeBuild
💡AWS CodePipeline
💡Code Commit
💡Git Clone
💡SAM (Serverless Application Model)
💡API Gateway
💡Build Spec
💡IAM Service Role
💡S3
💡Lambda
Highlights
Introduction to deploying a serverless SAM application using AWS CodeBuild and AWS CodePipeline.
Navigating to the Code Commit service and creating a new repository.
Cloning the repository to a local machine using Git.
Using the AWS SAM CLI to create a new serverless project with Python runtime.
Creating project files from existing sources and configuring the SAM application.
Running the SAM application and verifying the 'Hello World' message in the console output.
Building and deploying the SAM application with guided configuration.
Viewing the API Gateway endpoint URL in the deployment logs after successful deployment.
Creating a buildspec.yml file for deploying the application using AWS CodeDeploy.
Committing and pushing project files to the Code Commit repository.
Confirming the presence of all files in the repository and creating a build project in AWS CodeBuild.
Specifying the source, branch, operating system, and runtime for the build project.
Configuring permissions for the service role to access necessary AWS services.
Starting the build process and monitoring the build logs for success.
Creating an AWS CodePipeline for automated deployment.
Setting up the source provider and build provider in the pipeline configuration.
Skipping the deploy stage and executing the pipeline to initiate the build step.
Editing the app.py file to update the output message and committing the changes.
Observing the pipeline's automatic response to code changes and initiating a new build.
Successfully deploying the updated application and verifying the new message via the API endpoint.
Encouragement to like, subscribe, and enable notifications for future content.
Transcripts
hi guys this is ABI from gokjdb in this
video you're going to learn how to
deploy a serverless Sam application
using AWS code build and AWS code
pipeline
let's start by navigating to the code
commit service then click on create
repository and give it a name
hit create then clone this repository to
your local machine using git clone
next I'm going to use pie charm to
create a new AWS serverless project
inside my Repository
choose python for runtime then hit
create from existing sources
give it a few minutes for the project
files to get created then click on the
configuration drop down and hit edit
choose the hello world template as your
input then hit run
looks like our Sam application is
working as expected since we see the
hello world message in the console
output
next click on the terminal tab then type
Sam build followed by Sam deploy hyphen
hyphen guided
follow the prompts to set the
configuration for Sam deploy then wait
for the deployment to complete
after the application is deployed you
should see an API Gateway endpoint URL
in the deployment logs click on this URL
and you should see a hello world message
which means our application was
successfully deployed
next I'm going to create a build spec
dot EML file which we will need when we
deploy this application using Code
deploy
now let's commit and push all our
project files to our code commit
Repository
let's head back to the code commit
service and confirm that we see all
these files in our my Sam repo
next click on build projects under code
build then click on create build project
give your build project a name then
specify my Sam repo as your code commit
source
select the master Branch then choose
Amazon Linux 2 as the operating system
for the managed image
select standard for runtime then pick an
image
I'm going to copy the name of the new
service role because we'll need it to
add more permissions later
for build specify build spec.aml then
hit create
next let's navigate to the IAM service
then find the service role that we just
copied go inside this role then click on
ADD permissions then attach policies I'm
going to give this role full access to
IAM S3 Cloud watch API Gateway cloud
formation and Lambda
next click on start build then hit tail
logs give it a few minutes and if there
are no errors in the build logs you
should see the succeeded message
now let's create a code pipeline click
on pipelines then hit create
give your pipeline a name hit next then
choose AWS code commit as your Source
provider
select your repository and the master
Branch then click on next choose AWS
code build as the build provider then
select the my Sam build project and hit
next
I'm going to skip the deploy stage
because we are running Sam deploy in the
build step
hit create Pipeline and your pipeline
should start getting executed
automatically
give it a few minutes for your source
code to check out then the pipeline will
automatically kick off the code build
step
to look at your build logs click on
details in the build step then hit tail
logs
wait for few minutes for the build to
complete and if there are no errors you
should see the succeeded message
next let's edit our app.py file and
change the output message to hello world
dash version 2. let's commit and push
this change to our remote Master Branch
let's head back to the code pipeline
window to see if our code pipeline
automatically picks up this change and
starts a new execution looks like a new
build is now in progress let's click on
details and tell the build logs give it
a few minutes for the build to complete
then grab the API endpoint URL
looks like our change was successfully
deployed there you have it make sure you
like subscribe and turn on the
notification Bell until next time
تصفح المزيد من مقاطع الفيديو ذات الصلة
AWS CodePipeline tutorial | Build a CI/CD Pipeline on AWS
How to Run a Python Docker Image on AWS Lambda
Full Node.js Deployment - NGINX, SSL With Lets Encrypt
Laravel deployment with GitHub Actions
AWS ALB (Application Load Balancer) - Step By Step Tutorial (Part -9)
Intro to AWS - The Most Important Services To Learn
5.0 / 5 (0 votes)