Getting started with AWS SAM  Serverless 1

Author:

Foo Bar

Keywords:

aws lambda api gateway,aws lambda function,aws lambda node js,aws lambda tutorial,aws lambda tutorial for beginners,serverless architecture,serverless aws,serverless computing,serverless framework,serverless tutorial,serverless web application,aws sam,aws sam tutorial,aws sam introduction,aws sam how to get started,aws sam local,aws lambda,aws api gateway,lambda foobar,aws sam cli,aws sample projects,serverless hello world,serverless computing aws

Subtitles:
hello word and welcome to another episode of fubar in today's episode I want to talk about some AWS some if you are interested in watching more candid about surveillance or computing or software engineer practices in general subscribe to my channel in red button below I post a video every Tuesday so today is the beginning of a new series I will cover for the months of September AWS some yes some some has been out for a long time and I have not made a video about it so I think now it's time so I will create a series of four videos on some during September but that doesn't mean that this is the last of some you will see this is just the beginning and in all the videos if you want to see some particular topic leave it in the comment box below because I can create a second set of videos with the topics that you are interested in watching but this is the beginning so this is an introduction to what is AWS some so let's start with the elephant in the room what is AWS some some means a simplified application model and it has this really little cute squirrel as the mascot I leave it here so you can see it is really cute and that's one of the things that I have for some before I knew it and it's an extended way of doing cloud formation for making easier to create your lambdas DynamoDB tables and api gateway so basically it came after several s frame work and it's inspired a bit in it and it has new things and it has a lot of different things as well so with some as with several Oz framework you write your application and definition on llamo or in a JSON file and that will be like your infrastructure and that will be packaged into an hour file and will be uploaded to your cloud and we will deploy it with cloud formation and also with some you can do local testing you can use the application repository you can do the log you can check the logs you can check what is going on in your projects so it has a lot of features and we are going to explore some of these features doing this series but if you're interested in other particular features remember in the comments so I make a video so in this video I want to go hands-on on what is some how to create a simple application with one lambda and one API gateway and I want to show you how to get started with some if you have not already tried out on this climber I have never used some before I have done one or two tutorials with AWS that I don't remember much so that doesn't count this was my first kind of exposure without any kind of tutorial on exploring some so I will guide you through what happened to me as a beginner with some and maybe it's fun video to watch so that's the disclaimer and now let's go to the code and create a very very simple project as always the code link is available in the description box in a github repo so to get started with some what we are going to do is to go to the documentation that is available in the AWS lab repository called service application model there you will be able to see how to get started some but I was reading the documentation and I could not find any simple example on how to get started or neither tutorial so i will explore on my own how get started so the first thing you see is the cute squirrel it's explained more or less what some does and it tells you how to create your some and it explains what you can do with some and that there is hi to guide an example so I go to how-to and it says to write a some template they check the specifications and that's how to deploy and how to pack it I'll go to the examples and let's see so examples there is no readme so I just go to apps and they're still not with me so I don't know which one of these ones should I start with so hello word sounds quite promising so I will open the readme and the readme is empty that's good start and now I can go and open the template and in the template I'm able to see that it only has one lambda and I'm looking for something with a lambda an apipa away I will check the next one right next to it that it called HTTP request let's see what that one does with me stills is empty so let's go to a template um oh and there we can see that there is one function but there is no API so that's what not what I'm looking for so let's go back and let's continue browsing and then I found something called micro service HTTP endpoint there is no readme whatsoever but well let's take the template and here I can see there is one function and there is some kind of policies for accessing that they will under is an API so maybe I can use this as my base so I will create a new directory and there I will call it some tests basic project and I will get into the directory and I will create a new file called template yellow as I saw it examples so let's open this with Adam so I have here with Adam and I can just copy paste everything and let's modify it a little bit because I don't want the Dynamo table and I can see there that there is just the proper the policies but there is no table defined so let's clean a little bit this up let's change no.6 to note 8 and let's remove the policies for the access to the table because I don't need that and now we have one function and one API so let's change the path to hello and let's change the handler to be in handler file hello so if you see this is really really kind of makes very straight connection to what is in service yeah no it just a little bit different organized but it's I never saw a template like this before and for me it just makes sense so I'm cleaning up a little bit the descriptions and now let's change the name of the lambda because that's a long name so let's call it hello so now we have everything so you can see that there is the resources like we have in the server luciana or we put our cloud formation here we have resources and then we have hello that is the kind of cloud formation name for this resource and I call it hello and that's a function and it has some properties and the properties are where the code is for this function is in the handler das file in the metal hello we have not created that yet so you will not find it then the right time for this lambda is 8 from 10 the co uri it will be where this lambda will be packaged and we will get to that in a moment now the description for the lambda the memories 512 we can put whatever you want timeout is 10 seconds and we can put whatever we want and that's the event that triggers this lambda that is called API one is a type of API and it has a property that is a path hello add a method any now let's create a new file and we call it Handler - yes and in there we can see what is in the template in the example in the indexer yes there is kind of looking into the database so I really would not want to copy that code I will just put another code that is kind of similar but instead of doing things whenever we delete get post or put I will chasten our response with a different response so I will have the handler the hello method and there we will have a switch and depending on the HTTP method I will just send a referral message so I have the send response method that will just send different status code and a message so for the lady will say delete happened forget rule set get happen and blah blah blah let's continue reading now we have our project and we can see we read something of our package and we have to package this artifact so meaning that we need to upload this to a bucket and then it will be able to deploy to cloud formation so that's the code all right it's a dot so it means that it will be pack in the same directory and then we need to run this command that is there AWS CloudFormation package to upload the artifact to us free so the first thing we are going to do is we are going to create a new bucket I call it some test bucket foobar you need to put a different name remember buckets are unique and for all these you need to have installed the AWS Clee if you don't know how to install that I will leave you a link in the description on how to do it with instructions from AWS now we have our bucket and the next step is to package this so we will run AWS CloudFormation package that's the template file the name of the template we want a package in which s free bucket and we put the name of the bucket and then the name of the package file that it will be package template yellow so we press ENTER and it's packaged so now everything is in our bucket and it says that now we need to execute the following command to deploy the package template and it says that we need to do it orioles confirmation deploy template file that we just got and and the stock name but if we check the documentation that's not enough we need to put one more thing that is their their capabilities so so now we are going to run the deploy of the cloud formation and for that I will run this command it all us - - region and I will specify the region if you already have configured your region in your it obviously you can avoid this but I don't have it configure because I'd like to change the region I put it here and as I created the bucket in u.s. East one I want the return of these to be the same then I will put transformation and deploy and I will find template file and I'm in the directory that's named package template yamo and then the stock name I will create a new stock name that can be anything that you have not already created in your account in Eurasian some tests basic project that is the same as the name of the project and then the capabilities there is I am this you press ENTER and this takes a little while that is when he is deploying the template to cloud formation I will speed this up a bit and we can see what is going on in our cloud formation so we can see now that the stack appear and we can see that there are resources there is an REST API there is a lambda there is a role and we can click in the API and we can see that is some test basic project is there and if we go to stages we can see the resources we have hello and any and if we go to stages we can see that there is production and stage let's open stage and hello and any any method and there we can see the invoked URL that we can just basically paste in the browser and we can see that get happened because browser since I get and then we can check the lambda and we can see that it has a trigger from API go it has access to the log we can see down there the code that we just pulled and if we click on API gateway then we will be able to see the oral of the end point if we want to remove this is as easy as running AWS the saturation the region you are in to you don't need this if you have already configured it in your AWS clean but as I have not I have to put it here and CloudFormation delete stuck the name of the stock and that will remove the whole infrastructure from your account that was the video for today I hope you liked it if you did keep a big thumbs up and in the next video of this series we are going to work a little bit on making a little bit more complex project to see a little bit more about some and what we can do with it if you want to see something don't forget to leave it in the comment box below and I want to know are you using some inflection what is your experience with some and not surrealist framework I would like to know that so around here as always there are videos from my channel for you to watch so go ahead and click and if not I see you in the next episode of fubar

Loading