How To Deploy Serverless SAM Using Code Pipeline (5 Min) | Using AWS Code Build & Code Commit

preview_player
Показать описание



Video Transcript:
_
Hi guys, this is Abhi from Gokcedb. In this video, you're going to learn how to deploy a serverless Sam application using AWS code and AWS code pipeline. Let's start by navigating to the code commit service then click on create a 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 to 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 projects to our code commit Repository. 

Let's head back to the code commit where we see all these files in our my Sam repo. Next, click on build project 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 the 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. 

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 pipeline 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 as the build provider then select my Sam to build the project and hit next. I'm going to skip the deploy stage because we are running Sam's deploy 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 automatically kicks off the code build step. To look at your build logs click on details in the build step then hit tail logs. 
Wait for a few minutes for the build to complete and if there are no errors you should see the succeeded message.

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.
Рекомендации по теме
Комментарии
Автор

Woow. I can't believe how different this video is to your newer ones. I had to double check it was even the same channel 😂😂😂
I love your newer videos, your suit, facial features, tone and quick delivery is amazing.

Keep up the good work my friend, also, this was still a great tutorial. Thankyou.

Dfeneck
Автор

I was hunting on how to attach the IAM roles correctly. This video had the gold!

jakedanforth
Автор

Brilliant. Thank you! I think this took me 10 mins

darrylwilliams
Автор

Thank you Abhi, for sharing this video !! Is it possible to separate out build and deploy stage ?

janivimal
Автор

Nice. Was the lambda function integrated to that repo, and updates automatically after push?

gallant
Автор

Why everyone is silent about environment variables like database collection credentials etc.

praveenkumart
visit shbcf.ru