Building with SAM and SAM Pipelines on AWS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
just to quickly um give a brief introduction to myself like what paul was saying i'm a counterpart with paul um working around the enterprise customers i just finished my last certification so i'm fully aw certified also a serverless sme i like to double in my sales technologies and help customers in terms of you know whether it's going to be support issues or whether it's going to be architecture so serverless is where my strengths and you know my passion lies um swinburne university graduate um i'm a big believer and an advocate for serverless and even driven architecture a bit bit about you know personal stuff you know i love go-karting fast cars and i really love coffee um to a point where i've actually got a nice barista style coffee machine at home and doing latte art and whatnot so that's a little bit about me um so um i'd like to keep this session quite interactive if there's any questions please feel free to ask me um just to quickly recap our agenda today i'll do a quick level set um oh really my camera's gone that's all right just for for you robbie we are going to be monitoring the chat so you don't need to worry if somebody asks anything on the chat we will actually convey to you right away you just perfect workshop okay perfect and thank you so much really appreciate that all right so first of all intro to sam uh what awsam is then we'll build an api um just a rest api from scratch using awsan um we'll extend that api to make it a little bit more helpful rather than you know just a vanilla api and we'll quickly build a ci cd pipeline using aws sam which is a fairly new preview feature without further ado let's jump in so i wanted to quickly ask um the folks here today um who's actually used aw sam or serverless or any of the frameworks that's out there for you to help deploy you know serverless applications uh yeah i definitely have i i really like working with sam um aaron de haan have as well yep perfect perfect sounds good all right so just a quick um run-through of aws uh sam it stands for serverless application model it's got a nice little mascot there um so aw sam in essence is basically a framework for building serverless applications so if you think about running you know writing lambda functions and you know using cloud formation as iac infrastructure as code think about aws sam as a shorthand version or an extension of cloud formation that will help you really quickly build applications using this framework it is also open source so you can actually um do um pull requests um you know create issues and i i'd actually um advocate you doing that if you have any issues or um if you have any ideas about how to explore and you know extend sam you can certainly do that with our open source community um serverless has a few resource types i'll go through some of them today um oh michael um you're a serverless framework guy okay cool that's good so um i guess serverless framework i think um dan also mentioned you know the difference between um sam and service framework i'm not fully across um the serverless framework as i'd like to but basically it's it is again a framework it's very similar to aw sam um and then you basically aw sam is managed by aws it's open source um so there's quite a bit of similarities it's it's designer cg yeah absolutely um so i guess the idea is if you're going to be building a serverless application use framework is basically my recommendation whether it's going to be serverless or awsm whichever one you pick just pick something that will make your life a little bit easier to build these applications today what we're going to be building is a very simple vanilla api gateway um with a lambda function and that's going to be backing into a dynamodb which is our data store love cdk yes cdk is awesome and there's um synergy like um you know connectivity between sam and cdk as well that's also a public preview um cool so if you wanted to build what i showed you here it will look very similar to this if you use cloudformation which you know it's cloud formation is really good in the sense that it's quite flexible um it gives you quite a lot of flexibility in terms of what you want to do with it however you can see that it's fairly verbose so you'll have to write quite a bit of code to get a application up and running so that's where aws sam comes in so if you look at the [Music] design before you can actually run that same design using sam template and you can basically have this template run which will be expanded into the cloud formation that you saw before so i'll run through that a little bit more in detail so the transformation happens in line number two where it says aw serverless dash blah blah so that basically tells um cloud formation that this is a sam template and it needs to transform the sampling template into a cloud formation template so that is done via cloud formation um so yeah so this is basically the starting point and you can see there's a specific type here called aws serverless function this is not a cloud formation resource however it is a sam specific resource when cloudformation sees this template what it'll do is it'll actually create a lambda function in the background it'll extend it to a lambda function in the background um you will also see here that there's no api gateway um resource and that's expanded via this event section basically this event section tells you what kind of event sources will trigger the the lambda function and in this situation the event sources and type api which will be basically going to be expanded into an api gateway with its own stage with its own deployment and everything else that comes with it and underneath you'll see you know as aws serverless same simple table which is going to get expanded into a dynamodb table cool so with sam it's it's basically i i like to think of sam as a two-step process you've got the spam template um which will basically expand into a cloudformation template which will which is what gets deployed into our environment now the other part is the sam cli which is kind of your tool that lets you really locally build you know test debug and deploy applications um using using the sam template so you can actually create a local execution environment like a lambda emulated local execution in ramen where you can actually really quickly iterate through your changes um locally without any connections into the uw's yeah was that a question oh sorry that was someone didn't realize i wasn't on you know oh good oh good all right um so yeah so the the the latest um change our preview feature that came about with aws sam was the ability to create ci cd pipelines um i will go through that today the other thing that is experimental at the moment but it is really really exciting is uh sam accelerate which will basically synchronize your changes that you're doing you know locally with the aws um enrolment basically what that means is um you can change your code locally and when you click on well when you actually save that um save the the solution what will happen is it'll actually use the the apis the underlying apis the lambda apis to zip up and deploy that change into your functions and your api gateways which will make it really quick to deploy those changes into the cloud so you can get some really quick feedback when you're developing your solution so you don't have to necessarily work in the confines of a local environment which is an emulated environment you can actually do that connected to the aws environment as well which is going to be really exciting i just um can't wait to show you guys that today it's mostly about um the api creation the expansion and then um ci cd problems if i have a little bit more time i might actually um take you through sam accelerate as well cool so with sam pipelines um what it does it it actually creates some resources in the background um it will basically create an im user it will create a few roles that will allow the the solution or your ci cd pipeline or you know whichever technology that you use to deploy that into you know into your account using a ci cd workflow um at launch we had um support for jenkins um github actions and gitlab pipelines i'm not sure whether you're aware but now we do also support aws code pipeline as well which is what we're going to be using today because it's really easy to do it um on the there is enrollment and you can use it use your cloud9 in ram and to spin this up so we'll go through that today um [Music] that's really about it um [Music] any questions so far before we jump in hope i didn't take that long are we ready to go all right um if you're ready to go um if you can quickly get onto the url there um and then that will basically bring up your workshop let me try and yes cool okay is everyone here thanks paul all right so if everyone's here what i'm going to be doing is i'm going to walk through this workshop with you today um so we're going to be building the whole thing through so i'm hoping you have either a pretty wide screen where you can build bring this workshop on your left and have your cloud9 enrollment on the right or whatever but i'm just going to be going through the cloud9 environment with you guys so let me bring this up as well all right so basically what we're going to be doing is first we're going to be creating a cloud9 environment um everyone okay with the cloud9 [Applause] cool um so let's go and create we're gonna go through the setup um i'll just use the sam workshop here please let me know if anybody um nice chips i'm not sure who that is that's making so much noise kelly it is the chips i believe yeah yeah it was a good snack but we'll museum for the rest of us because we're all getting hungry oh yeah now i gotta go and get a packet of chips sorry guys um just give me a quick second my session has expired let's give it a bit of time okay so let's create the cloud9 environment first of all um cloud9 if you haven't used it it is our cloud-based ide um so give it a name next step nothing major we'll create just a vanilla environment it'll give it a bit of time so how is everyone doing um okay so far any questions about aw sam anyone hasn't used aw sam so for awsn uh robbie we can still um put the um cloud formation template right for example things mr sam is not supporting yeah so anything that cloud formation supports you can run it via aws sam because awsam is basically a superset of cloud formation so if you don't have a resource that is not covered by aw sam you can just use regular cloudformation with your aws stamp template there's not much of a difference ultimately it goes into cloud formation it'll expand the the sam specific resources to cloud formation resources and any other regular cloud formation resource will be just a regular cloud formation resource so yeah anything anything can be support that can be supported with cloud formation you can write it with sound template as well [Music] um there's some background noise coming yeah there's some background so the other thing robbie is you mentioned some of the resources are not defined in the sam itself for example api gateway url etc how can you access those things i'm sorry say that again um so some of the as you mentioned like api is not defined explicitly on the sand um but we need to access the url for example uh all other things in the other parts of the same framework or maybe cloud formation you edit on top of the same sam template so how do we get those uh resources are you going to cover that as well yeah um let's go through the the sam template once we go through the creation process and we'll we'll go through that part as well yeah absolutely thank you no worries um cool so once we got the sam template up and running i'll do a bit of cleanup get all of this out of the way okay so the first part is the setup um and just check whether your sam version is okay um you don't necessarily need to um uh you know do an upgrade or anything off the sort it'll be um as long as you got 1.3 31.0 you should be okay so i'll just quickly check whether that's the case on mine i'm guessing it should be and then i can skip the skip to actually building an api so first thing what i will do is i wanted to do a sam init which goes through the the um the process of you know asking me the quick questions cool um so i'll just go through the quick start for now but basically you can use your own um custom template as well um with sam cli the templates are run using cookie cutter so if you wanted to create a you know your own custom um template you can certainly do that but i'm for this situation i'm just going to be using the um the the built-in ones i did not know actually ecr was supported instead i did oh i haven't been initializing for a long time now yeah yeah so sam does support image um container images as well um so this is a situation where you have um you know packages that's beyond 256 megabytes right um so if you got you know things like aiml packages or anything that's pretty hectic or heavy you can start using um container images as well and aws sound supports uploading that does it sorry a quick question here um does it support uh ecs or eks deployment wise because yeah anyway that's the question that's the support so so the the the deployment is still to lambda it doesn't support um running it into ecr sorry ecs or eks so lambda supports um container images um basically what that means it is a package um packaging mechanism not necessarily running a container on lambda it's more of a packaging mechanism there all right so if you wanted to package anything beyond 256 megabytes you can't use a zip facility you can basically use a docker file you can package the whole thing up and then upload it into lambda which will work within lambda a copilot might be something that would be worth looking into if you're looking for that [Laughter] that's someone being silly um is somebody zoom bombing it's the same person logging in with different names i've seen it before um co-pilot might be what you're interested in looking at oh thank you very much i'll check that cool so we'll just quickly run through some of these um so the runtime as you know you can use quite a few today we're going to be using node.js and for the project name i'm just going to call it api what will happen then it'll go through and get some of the the templates that's available um today we'll be using the hello world um example so i'm just gonna pick number one so this is going through that interactive process and once that's done what will happen is that you'll see on the side there's an api folder which contains pretty much um all of the um all of the artifacts that you need all right so let's go through some of those folders first of all i wanted to run through the template.jaml so the template.gamble has the transform like i mentioned before which tells cloudformation that this is a sam template and then you can see that there is a hello world function which is the aw serverless function and once this is deployed you'll see that the hello world function will be actually getting translated into a lambda function also like i mentioned before there's an event section which basically goes through the even sources and you'll see that the type is an api and don you asked the question about how i can get the um the url out of this event source and that's through this function basically it it will get the um the rest api um the the sub domain out of this and then you can use that and the the region and you can basically make up the the api gateway url does that answer your question yeah it does thank you awesome so either you can use an event source here or you can basically run a a separate function a separate api called api gateway and you can basically say it's aws serverless api and then you can use that as a you know a resource into your event like that so you can certainly do that as well so um yeah the documentation will help you in terms of um what you can do with awsm but for us today this is the easiest way to get started so [Music] we've got some hecklers today i'm kind of annoying i'll just keep walking was that coming i thought it was soothing it was like haunted house like uh you know uh halloween it's funny all right so first time happening to us i guess anyhow sorry about it go ahead that's all right all right cool so let's try and deploy this shall we so if i go to um the api folder i can just do a sam build which will build my solution and you can see that it is actually doing the packing um doing npm installs um cleaning everything up and it's all ready to build what i'm going to be doing now is i'm just going to do a sam deploy guided which will give you give me a interactive experience around what about how i can deploy this across so for the stack name i'm just going to call it api region the same confirm changes i don't want to confirm changes it automatically um go through it allow sam cli role creation yes please no authorization defined is this okay i'm just going to say yes to this save arguments to the configuration file yes and the configuration file is i'll keep most of this into defaults for the moment and now you'll see that the sam sam cli will basically deploy this across into your aws environment so it's first firstly checking um what kind of resources that needs to be deployed and it's just going through the process at the moment [Music] okay so if i open up another tab and look at card formation you can see there's going to be a new um let's wait for this to go through first of all but once it actually starts you can see that it's actually uploaded the the template uploaded the the solution the lambda function and it's now going through the creation of this dac so you can see the the function roles the function the deployment the production stage the rest api all of this is now getting deployed into your environment and all you had to do was just specify just technically that part and you've got your lambda function your permissions your policies your api all getting deployed so hopefully now you get an idea as to how quickly you can start you know building your serverless applications with um aw sam um yeah and you can see now there's a stack getting created so let's look at that stack as well now if you look at the template section here it'll show you what is getting deployed but if you turn this on you'll see this is the actual cloud formation template that um is getting deployed just imagine having to write all of this you know just to bring up a you know a simple you know api so that's that's basically the power of sam so hopefully if anybody you know anyone who hasn't run through aw sam this is the reason why we advocate running and deploying serverless applications using uwsn all right oops sorry about that through this again any questions so far already quite bunch cool awesome so let's look at that and you see that everything's created and updated all right so let's go and go and make some changes here so if you look at the the the folder structure you'll see there's a hello world folder here that is our lambda function so if i look at the app.js file this is essentially the lambda function that got deployed into aws and you can see that it's got nothing nothing really crazy here you've got the hello world um before i do that let's go and check what the output of that is actually so if i open this endpoint here you'll see that i got my api up and running there's a hello um path to it how do i get this off here we go um so i've got the message hello world coming back so if i go back up here here's my lambda function now let me just quickly change this to hello melbourne meetup right so i saved that what i need to do then is basically save the the file you do a sam build and sam deploy basically it'll start building up the lambda function and it'll deploy it again so if i see here it says hello world by the time it actually does the the build and the deployment did you save i thought i did let's try again okay this time it seemed to have worked because it said uploading to api so you might not have saved the last time i did that so you can see that it is actually modifying the function and the rest api it's going through the update process and in just a little bit you'll see that it's changed so the latest changes have gone into aws you've deployed it look to aws and now you can see the the endpoint now changed cool all right so that's all good um the next thing what i wanted to do is to actually add a data source so you can see that we're slowly evolving um this application there's a question from sidhar um question is where can i find the cloud formation template generated by the sam yeah absolutely so if you go into the the um the template here cloudformation stack you can see there's an api stack that got deployed and you can see the the generator stack here so this is the this is the sam template that was deployed and this is uh the generated cloud formation stack so ashley asks the question can we hook those steps build deploy on premise jenkins pipeline uh are we talking about the the pipeline now no no if if it's on if it's the on-premise jenkins pipeline and we integrate those steps of build and deploy i believe ashley was trying to ask yeah absolutely yeah absolutely so all we got to do is within the agent you install sam cli and then you can just run you know run you those commands which will basically build up the the um the story and you can just deploy from there thank you cool all right so um let's go through creating the the template here uh sorry the the table so i'm just gonna copy and paste some code um just to make it a little bit quicker so first of all what i'm going to be doing is i'm just going to add a serverless table and it's going to be aws serverless simple table which is again a sam resource and the property i'm just gonna call it give it a tag and a name and an api um and then what i'm gonna be doing is i'm gonna be adding a policy to the lambda function so it can actually start writing and reading to it so over here i've just added a policy for my function which is a dynamodb crud policy this is also a sam uh sam you know specific policy which is going to get um expanded to a proper you know uh uh i am policy what i will then do is i'm going to add some environment variables so that you know i just reference the the table name here so that you know when i'm running my lambda function across multiple environments i can use different tables even when i'm using the same account all right so that's all good what i'm going to be doing then is i'm going to be going through and just close this off put this here okay so i've made the changes i'm going to be doing again sam build and sam deploy now hopefully at this point in time you'll see that my function role there'll be a change to the function role there'll be a dynamodb table that's going to get created okay so over here you can see that there's a new dynamodb table that's going to get created a new ion roll sorry a modification to the iron roll and the modification to the lambda function and the rest api all right so once while that's happening we'll just go to the next step which is to actually manipulate some data all right over here what i'm going to be doing is i'll go to appjs while this is happening i'll include some packages so aws um already comes with you know uh your lambda um you know uh the the the runtime so you don't have necessarily have to include that across but however uuid is not something that's available there so what i'm going to be doing is i'm going to be adding that package uuid so over here what i'm going to be doing is i'm just going to go to the hello world table sorry a hello world folder and then i'm just going to run npm install so that'll actually install the npm package on that folder it'll add to the package.json file you can see it here now that there's a dependency of uuid package for this solution all right so now that i've used the the uuid i need to put some you know make some changes to my lambda function robin let's go sure um two questions one is do we need to run npm install every single time we change the package json or we did automatically run it on deploy um [Music] so you'll have to build your solution which will basically and do the npm install and package everything up for you so you don't necessarily need to run npm install every time um i just ran npm install because i didn't want to bother you know running you know going into package chase and then putting in all these things because i couldn't you know couldn't be bothered running the uh the you know checking the um the convergent numbers and everything else yeah the second question is uh again about dependencies does sam support layers lambda layers yeah absolutely does yes today i'm not going to be going through lambda layers unfortunately but um sam certainly does support lambda layers thank you cool um [Music] so what i did here is i've just added some parameters a table name coming from coming from my enrollment variable remember how i added the enrolment variable so that's coming from here just giving it a description the time stamp whatever um and then what i'm going to be doing is i'm just putting that item into my dynamodb table so folks this is just demo demonstration demonstration purposes only um i wouldn't want to create a dynamodb db table a schema like this that's another session altogether so now that i've got the dynamodb table um you know writing to the dynamodb table what i'll be doing is i'm just going to grab the response now doing a pretty ugly scan here don't do this you know don't do this at home or in production um and then what i'll be doing here is i'm just gonna add the count and that's it so at the end it'll just look like this what we've done so far is we've got the table we are writing to the table and reading from the table so very simply again all we got to do is go back to our api folder and then do a sam build which you can see now it's done doing an npm install so it's going into the package aws sam um package here it's building everything you can see the hello world function this is the one that is actually getting zipped up and deployed okay so i'll just do a same deploy and away we go so if i look at here this should technically change up let's have a look so you can see there's a count now count is one if i refresh now it'll go to the dynamodb table write a record work out what the the number of records are and it'll just iterate through so now we've just um started you know actually persisting some data in the dynamodb table and pulling the the information now so this is very you know very rudimentary example of how aws sound works but you hopefully you get the idea all right so the next step is to actually go through the crcd pipeline so this is the the new feature that was um released so let's go through that how we would create a sam sam pipeline here all right so what i'll do is i'll expand this again all right so first of all what i'm going to be doing is i'm just issuing a command sam pipeline init dash dash bootstrap so you can run these two in isolation if you wanted to bootstrap basically sets everything up in the sense that it'll create the iam users it will create the um the roles that's required um and one of the things that i didn't actually mention to you guys is that this pipeline you can have it set up so that you've got two accounts um one is your dev account and the other one is your product count if you wanted to think about multi-account deployments you can certainly do that using sam pipelines as well so i'll just use the aws quick start pipelines template at the moment and you'll see that like i mentioned before you can actually deploy to either jenkins or git lab or github actions or now you can do that with aws code pipeline so for today's session let's use aws code pipeline now i've used a template that had two stages um if you wanted to use three stages you can you can configure that um using your own so for today we'll just keep to the defaults um so this is asking me um do you want to create these bootstrap resources i'll say yes and then it asked me about the stage one set up so for stage one i'm just going to call the stage name dev i'm just going to use the default name profile so when i selected default it actually picked up my account account id with it as well so for these ones i'm just going to keep ap southeast 2 um i am user pipeline execution role please create all of these for me and the card formation execution role if you have your execution roles you can basically specify these things here if not sam will help you create those so here it's asking me whether there's any um image type lambda functions and for this it's a no but if it did it'll actually create the the underlying ecr repository and everything else we did as well all right um is this pipelines available to all of us now or yeah absolutely is yes so um if you up um update your cli to 1.3 31 um it's actually available now excellent thank you so proceed with the creation yes so this will actually create the the i am user the execution role the the cloud formation execution role and the artifact bucket so think about it this way it will create two separate stages the dev and the prod um you can have it running in the one account or you can run have it running in two accounts um and then if you want to have multiple stages you can if you wanted to expand it you still can like remember how i set up over here i said use aws quick start pipeline templates so you can i could have easily picked number two which is my own custom pipeline template as well so you can certainly have the you certainly have the flexibility to um you know basically do whatever you need um so we'll just wait for this to actually create the required resources it will take a little bit of time so hopefully not too long that happens what is that that's pretty cool okay so weird did you do it intentionally is it i don't know that's not me oh okay so you can annotate oh hello oh so that's that's me there you are we discovered zoom as well good there you go that's pretty cool actually is that you're doing it in zoomery in cloud nine nah i did it in soon yeah zoom yeah cool right it's pretty cool anyway um so i'll go through these sections as well do you want to create the bootstrap resource yes so i'm just going to give stage num name prod um default um and the region we'll just keep to the defaults here pipeline execution role cloud formation execution role so this is basically doing my second stage so i'm just going to go through the defaults here for now now it's asking me for a summary i am happy with it i'll say yes and then should we proceed with the creation i'm just going to say yes to this so now it'll create my stage 2 which is my prod stage with the the the execution roles and the artifact bucket while that's going through any questions come through at all who's actually running through this live with me well awesome good excellent yep i am tori is doing it locally he's not using cloud9 i guess nice okay cool yeah you can certainly do this locally um very cool all right so awesome we'll just um give it a couple more minutes until this happens so so yeah i think the the beauty of this is you know the the developer productivity there the fact that you can really spin something up really quickly um and hopefully you don't have to do this every single time so the bootstrapping part you don't necessarily do it need to do it all the time it's the the next part that we will have to do um for each new application that you need to create all right so checking for existing change stages i'm just going to be saying code commit today because it's easier to set up everything through through aws for this for this workshop um the code commit repository i'm just gonna call it api it ha we haven't created an api repository um yet but we're gonna be doing that pretty shortly template five parts yep i'm just gonna leave them all the same here i'm just gonna say my stage one should be dev and it's asking me for a stack name for stage one so here i'm just going to be calling it api dev stack stage 2 is prod and i'm going to call it api prod stack uh i wish i had this like a couple of months ago it's i mean being able to create different stages yeah incredible um yeah i had to create i don't want to even talk about it yeah i mean it that's the thing right like it's it's all that heavy lifting that's been taken away from you and also the fact that if you if you're working in a pretty constrained or you know environment or you've got some compliance things that you're gonna really constrain yourself into you could certainly do that as well so this is not yeah i've done all these things with um bash scripts yeah changing the variable names and the best scripts into templates and oh my yeah anyway i can't even stop it it's beautiful i love it yeah that's it um so yeah so this is actually created um the pipeline configuration files if you look through on your um left hand side you'll see the the configuration files already um created for you i didn't have to write a single thing so you can see the build commands they're all here the packaging so that's all the build and package if you look at deploy you can see all of these things yeah available to you all right [Music] cool so let's let's actually create the repository now so i'll quickly create a repository aws code commit create repository all right so that'll create me a repository a good repository um i'm just going to set up the the global first last at example.com why not um for the git ignore i'm just going to use the um i'm just going to ignore the aws sam build folder because that's going to get get you know built every time um so that's done i'll go back to go back here i'm going to create the first branch the main branch cool um my files commit and i've got the the commit to my local repo next thing what i'm going to be doing is i'm adding the remote and and that's it basically the next step would be to push to my remote so what we just did is create a local repository created a remote repository in code commit connected the two and push the changes over to the remote repository so if you go into your code commit so code commit is basically a git repository fully managed git repository on aws so you don't necessarily need to use code commit you can use github gitlab whatever code code repository that you need to work through so i just created a api repository and you can see all of my code changes are now here all right cool that's done now let's create the pipeline so if you go into your code pipeline yaml you'll see that the the command that you have to run is already here but for this workshop i've just got the command on the um on on on the post here anyway so i'm just gonna copy and paste it so this will probably take about five minutes um to deploy this is going to create a full pipeline a code pipeline the the build projects it will create the service role the buckets um and the bucket policies basically the whole whole thing from start to finish so let's just wait for this to come through and you'll see that code pipeline will be initialized for you so for those who haven't used code pipeline it is a fully managed um code you know pipeline for a uh for a lack of a better word um so if you look at code pipeline here you can see that um it is another fully managed service from aws it'll go through and sets up your pipeline here robbie yeah i would think this would be more automated with the gitlab because it has all the specific files the gitlab is looking that would that be would i be correct that would be a code pipeline generate step i believe in gitlab so gitlab will have its own pipeline correct so so it is again a choice um in this situation whether to use code pipeline or if you're using gitlab you can use gitlab pipelines if you're using github you can use github actions if you're using jenkins you can use jenkins pipelines so in this situation i mean for this workshop i've used code pipeline because it makes it easy for us to go through the workshop but you ultimately it's about flexibility and the fact that you can use you know whichever solution that you're working on currently you know it goes goes a long way um again i guess this code pipeline generation is a one-step thing right it's just the first bootstrapping next time when you push the new code it will automatically trigger the pipeline absolutely yes so this is the first and only time for your application that you'll have to run this so if you create a new another new application you i would suggest you'd want to have a separate pipeline for that new application but not for every change that you do within the application so what we'll do is while this is happening um we'll just go and actually make a change and see how it will promote that change using code pipeline and the fact that you don't necessarily have to do this again and again i just wanted to quickly check yeah no that's okay um nothing fancy here um if you go through the code pipeline yaml you'll start to appreciate what this new feature is all about um just for code pipeline that is so you'll see that the whole whole stack is being auto generated for you you'll see the source here the the fact that you can you know can get the information from your repository your pipeline so this is cloud formation template for the code pipeline yeah automatically generated for you so all of that you know if if you had to build a secure pipeline for your application you know you wouldn't want to run and write um all of these things by yourself so that's where code you know sam pipelines would come in to help you know run these things for you so the whole thing is automatically generated and the the fact is that all of the build specs as well like for each and every step that build and package the deployments um you know if there's a feature the the feature releases um integration tests unit tests all of that is basically bootstrapped for you so you don't have to do much i guess that's basically the power of it so let me go through to code pipeline and see okay so you can see that it's actually picked up my um first commit and it's running through the changes so it's actually taken my um change from source you'll see that the you know it's already hooked into code commit it's updating the pipeline which in this situation there's there's no changes to it it's going through the build and packaged stage so if you look at the details section here you'll see that aws code build is actually running through the build spec um issuing the commands and actually starting building and packaging it so you'll see all of these things are here for you and you can go through all of these to work out where you're at if you need to at this point in time it's actually you know installing the packages updating it robbie yeah um it's good that this was this building and deploying it to to to respective environments but i tend to run a sam build and deploy from local so would there be if i if i deploy from local and then merge my code to master would there be a conflict in terms of deployment will it detect that it's already been deployed i hope the question is clear so so i guess if you're deploying it um manually and if you're deploying it locally you'll have your specification set up already so you had your stack called api right however when we did the same pipeline creation we called it different stack names so we called it sam sorry api dev stack and api prod stack so so if i go back to cloudformation if i can get this away here we go so you can see that the one that i manually did is api yeah but the one that i'm deploying now will be called a different name so this is a pipeline stack which deployed the pipeline but once it hits the deploy part which is here deploy test it'll actually create a brand new stack here yeah yeah that makes sense all right makes sense yeah so you wouldn't have a conflict as such yeah makes sense so i'm using the same account for this to deploy to test and to deploy the prod but ultimately if you're thinking about a multi-account architecture you'd want to you know deploy it into two different accounts and you can do that via your name profiles but for now for this workshop it's going to be deployed into the to the same account yeah that's also interesting uh topic in itself using different accounts for different environments and generally something that is recommended particularly in the enterprise yeah environment perhaps yeah you wouldn't you would want to keep your non-production and your production in um separate accounts just to minimize the blast radius i would expect yeah yeah that's correct so i'm just going through the deploy test stage at the moment and you'll see that it's going through the the updates going through the whole nine yards go on through the build phase so it's running the same deploy part you can see it's actually created my um so going through the stack change set it's saying okay i need to add all of these just as what you did locally it's doing it now using code build code pipeline and actually deploying the the stack for you so you can see that now i've got an api dev stack which is separate to api yep i can see thanks robbie all right all right so this is going through just give it a little bit more time and we'll just get the the dev stacks output you can either get it from here or you can get it from the cloudformation stack as well you can see it on your outputs i can just click on this and we've got our dev api now um connected to cice pipeline so i guess the the next step is to basically go and actually see the the power of the cicd pipeline by going into your app.app.js and changing it changing it basically and see how this would go and do the deployment for you automatically so i've made a quick change into myapp.js i'll just quickly check so you can see that i'm just going to be making a quick change here quick i'm just i'm just going a little rambo here so i just do a get push i can't type today and you can see that i've just pushed my code into code commit and theoretically that should kick off code pipeline again so if i go to code pipeline look at my pipelines it's already picked it up so the the commit message was a quick change and you can see that it's actually pulled that information just as quickly as i um push the changes upstream so now it's going through the update pipeline i'm not sure exactly which one which one was it not this one it's this guy so we'll give it a couple of minutes for this to go through so you can see that actually it's deploying into production while going through the next stage here so deploying to production my initial commit is still underway however it's actually picked up my latest changes and it's going through the next phase of deployment as well robbie there's a question from zikai the question is would it be possible to configure canary or blue green deployments if yes where can we specify the option yeah absolutely um so with aws sam you have the option to put in the details of a canary or a blue green deployment um let me quickly see if i can find the specification um so what will happen is that it'll actually create a code deploy which will actually go in and do the canary release for you automatically i'll just i'll bring that up while this is happening here we go so there is a um where is it okay so what you can do is you can set up the deployment preference for your lambda function and it'll do a canary you can set a type and there there are some specific types that you can select and which will basically do the the canary 10 10 minutes or 5 percent every 10 10 minutes so there's a few options out here we go um yeah so you can select whichever one you can do and all that ones if you needed to which will deploy a code deploy um which will do the the um the branching off it and then moving from your blue to green cool and it makes it really really easy to get started with this then you got the opportunity to do um hooks as well so you can have a little bit more control of what happens before the traffic hits and just after the traffic hits so yeah it's pretty pretty powerful and pretty easy to use all right so hopefully this is going through build and package it succeeded let's go back and check where things are at so it's deploying to test hopefully not too long to go so it's doing the latest deployment now so in a little while you'll see that this would have changed from hello melbourne meetup to hello clcd and i didn't have to deploy anything i didn't have to do a local deploy i didn't have to do anything at all all i did was make the changes and push the push the code into code commit and it could be whichever depository that you need it's updating progress and looks like the update is complete so let's have a quick look here we go now you can see that it's changed the message to hello crcd the count is still working that means i've got a service table dynamodb table underneath and i just deployed that via crcd so that's pretty much all i wanted to cover for today um before anything there's a clean up section here please go through that and delete your stacks um delete your cloud9 in ram and i'm going to be doing this right after this workshop just so that you know there's no charges coming through we want to make sure that you know you you guys don't necessarily have to pay any any more than what that you need to hey robbie did you in the latest version of sam cli does it support arm yet um for lambda like this is the flag that you put in like architectures and i didn't but i'm not sure whether they updated it so under the function of the properties if you add that you should be able to deploy that and it should work but i don't know whether sam cli supports that yeah i'm i'm not super sure um yeah i'm not sure i might have to get back to you on that one put it in cloud nine and push it up and see what happens let's try it um yeah let's try i would say it would work because is being a superset of the club the the sam cli does a validation step and a couple of weeks ago it didn't but i saw a new version came out i was just looking now so i'm not quite sure if it's there or not like it depends which version is the same cli you're on so so i guess if you didn't support it and you still want to use it you can actually create an actual lambda function if you really wanted to um yeah you can um like the way i did it was i edited the same source code and changed it right but but i'm not sure whether sam cli is updated like depending on which version did you update it to the most recent version i've only updated to 131 um i think it's monday night cool so yeah so i i guess it's throwing yeah yeah so yeah so there you go yeah for anybody that's interested like well yeah i'm pretty sure like i know the cloud formation supports it but i think sam cli like two weeks ago it didn't but it looks like on a repository 12 days ago they updated it nice um so if you're using like node or node or python especially is very easy to move across to using arm yeah and it's like you know up to 34 price performance improvement nice one yeah oh yeah this is this is a great workshop probably i'm sorry thank you it's great yeah it was great um paul is it cheaper to run on arm yes um i think up to 34 um price performance improvement like i think it's straight up 20 more more um it was 20 cheaper i think i'll double check check that nice all the more reason to get the latest sam version exactly exactly um i'm not sure i we we're out of time now aren't we guys yes i think you can go for a minute yeah i i don't think i don't think i can go uh for a minute probably need about half an hour but i just wanted to um if if anybody is curious about sam accelerate and want to see what the developer experience is going to be with sam accelerate i would highly highly recommend going through some of the the videos on youtube um and see what this new feature is all about that's that's all i wanted to say maybe another workshop on sam accelerate guys on another day but i'm really excited about it um yeah so it's pretty cool yeah maybe just close-up question so there were people including myself using the older versions of sam and how easy is to migrate the old you know sam templates sam versions etc to this new uh uh ci cd as well as the uh accelerate stuff is it like straightforward so i i the templates would most likely um be the same it's just about the the power is basically coming from the sam cli itself so you need to update the sam cli but not necessarily um the the templates themselves so if you wanted to quickly iterate through um you know and use sam accelerate or sam pipelines all you have to do is actually create you know get the the the latest version of sam cli which will create the templates for you but existing template that you actually need to have to run your application you don't necessarily need to change anything at all thanks sir excellent thanks robbie no worries um let me just stop share now clean it up later any other questions um to sr like yes we will upload the the recording to our youtube channel uh i'll send you the link to that and while i get that youtube channel do you dahan do you want to do the there's 14 people left someone can get a free copy of um anything of jetbrains license key so just doing another random generator between 1 and 14. yeah i was i was talking to myself for you keep saying anybody can win this but when my name comes up you never give it it's just not fair like 14 is it do you see my screen all right rolling it for 14. [Laughter] zen so zen if you um if you reach out on the slack channel to myself or dahan um we'll go ahead and send across that jetbrains voucher for you and tori also said earlier that you can't wear the t-shirt so let's re-roll the t-shirt so do it again from 1 to 14. all right so let me do that 10 10. so rohan ahmed if you if you reach out to me um or dahan on slack we'll um we'll hook you up and we'll get your address and send your annotation at ius t-shirt as well um on that note uh please join to our slack channel um or invite your friends to join our slack channel it is on the new page as well as on the chats of this meeting thank you paul and of course robbie for this great great workshop i've learned a lot to be honest i was i was doing my heads down writing my codes i guess i miss some of those this great enhancements to send and i'm going to go ahead and apply to my existence project so they are looking really good particularly cicd and as i keep saying i was writing best scripts and changing the name of the variables and all those kind of things stack names etc that was really painful this is just going to clean up so much code now um i am sad but at the same time very happy some mixed feelings today uh thanks again robbie um milan milan also is our organizer so please reach out to milan as well if you need uh if you need anything or any help um anything else we need to share paul that i miss maybe again if you're interested in putting um putting a a blog post on this reach out to us as well we we will help you to edit the content etc and then we post it on our blog page with your name of course so in any way if you have any ideas as paul mentioned in the beginning and if you want to do a workshop or hands-on demo please do reach out as well um and that's basically it paul i guess it's up to you now yeah yeah that's it thank you thanks a lot robbie i think robbie you had a feedback gathering did you want to get the feedback i do um it's a little late and i actually super crazy for me i actually forgot um let me just quickly how do i do this um do i just um put in the the link paul yeah you can just paste in a link into the chat that would be fantastic um let me just um grab it here so today we had a first on sand pipelines we also had a first of getting like zoom bombed was that the first time like so many came in it's the first time we've ever seen it happen because we've already done it this time like something different i think people have lots of time in their hands who would think zoom bombing is going to be a thing and put time into it to make it happen like i'm pretty confident that's all automated oh my goodness but someone needs to write that automation code right like why i think so michael you are right too many people are spending way too much time i know i know oh they have to have some level of entertainment i certainly got a kick out of it the chip sky was real fun the way he started hitting chips oh was he not a regular regular person i actually thought it was a fake that was a fake person i'm pretty sure oh was it wow you actually muted him paul and then he unmute himself yeah it was a fake person it was just it wasn't a real person and that's what that's what kept happening and then i realized i could lock the meeting and then no one else came oh wow okay interesting that's hilarious oh yeah um there's a feedback they can't open the link uh robbie that you put i'm opening it oh no it's opening it's opening okay it's opening okay for me sorry maybe you should click one more you don't copy and paste because there's a dot at the end yeah ah yeah sorry about that you just click it so the poll sling is all okay without the dot the full stuff yeah it's always a trailing or leading space right always thanks guys really appreciate it i'm really happy to be here um if there's anything uh feel free to reach out i would love to run a separate session on sam accelerate when it's actually preview you can actually start using sam accelerate if you wanted to start installing it yourself um but yeah it could be another another time another day but yeah anything serverless i'm pretty open to have a conversation anything aws i'm super keen to have a conversation as well so yeah please feel free to reach out really enjoyed it thanks guys thanks robbie that's uh great so um without shame on putting everything extremely sensitive on the form so if you want anything a half of it is mine okay just so you know nice work thank you thank you that was great and thanks paul again for for organizing catching up with robbie as well thanks paul thanks robbie and thanks don it's awesome yeah thanks everyone coming along special thanks to robbie take care all and see you next month all right live show fails bye bye
Info
Channel: AWS Programming and Tools Meetup
Views: 111
Rating: undefined out of 5
Keywords: AWS, SAM, Serverless
Id: Xudsx56svns
Channel Id: undefined
Length: 86min 10sec (5170 seconds)
Published: Fri Oct 15 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.