Deploying AWS CDK With Github Actions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's going on everybody my name is michael lavanne thank you so much for joining me today and what we're going to be doing is combining the aws cdk with github actions so we're going to have a cdk project and what we're going to do is we are going to deploy that cdk project via github actions so what i have here under cdk aws and of course you could find this in my github repository specifically the youtube repository i have just a plain jane aws cdk app i haven't done anything to it if i open up app.pi for example you can see you know there's really nothing going on here and that's kind of the point we don't want to deploy anything you know specific right now i really just want to show you the deployment for something basic or just really any project to be honest with you so these workflows are really all going to be the same now i have my github actions workflow file here my yaml goodness and what we're going to be doing with this is we are going to be taking this cdk aws directory and deploying it via github actions so as we can see here i have a name and it's called deploy aws cdk and then on this is how you tell github actions when to deploy like am i going to deploy from the main branch if it's pushed to the main branch if any code is pushed there a pull request to the main branch etc now just to test this out and depending on what type of workflow you have if you're in that continuous delivery model or that continuous deployment model you might want to actually go in and run this deployment manually so i have a workflow dispatch here and what that does is that allows me to go in and click a button and get of actions to deploy it so now i have a few jobs here and before we talk about the jobs i do want to mention that i kind of put this together myself without using one of the aws cdk tasks or plugins that are already in github actions the reason why is because i didn't find like an official one from aws or from github or anything like that so instead of using somebody else's and realistically i don't know if it's going to go away or not i just created my own here so under aws cdk we have runs on on line 15 so we're saying that this deployment is running on ubuntu and then we have a few steps here starting on line 17. first is to check out the entire github repo on line 20 we're going to be configuring our credentials so i'm going to show you this in just a second but really all you have to do is go into the github repository go to settings go to secrets and then add in your secret so i have two secrets one is called aws access key id the other is called aws secret access key and then i'm specifying my aws region here so now here's where i start to configure the ubuntu box to install cdk and run cdk so online 27 here you see that i'm installing node.js because to install the aws cdk we're going to be using it as an npm package so online 31 we're saying npm install aws cdk next on line 33 there are of course going to be requirements that are needed for the aws cdk like the library itself so we're going to be installing all the requirements in requirements.txt for the aws cdk and then finally on line 37 we're going to be synthesizing the cdk application and as you can see i'm specifying my working directory which is cdk aws as we saw earlier and then i'm going to be deploying the application so with that let's head over to github and we'll check out that deployment now before we get into the deployment here i just want to show you so i'm under my youtube repository and i went under settings and then i'm going to go to secrets so under secrets here is where you can add in those secrets for the aws access key id and then the aws secret access key and you can call them with the environment variable so i'm going to go to my actions here and as you can see i've already run this but we're going to go ahead and we're going to run it again so i'm just going to go back to the code really quick under github workflows directory i'm going to go to main.yaml and we can see this is the same exact yaml as we saw in vs code so i'm going to go ahead and i'm going to go back to actions i'm going to go to deploy aws cdk and then as you can see it says this workflow has a workflow dispatch event trigger so i'm going to click run workflow and then i'm going to run my workflow and as we can see this has started so let's go ahead and open up this workflow right here so this is going to go through a few different things here it's going to check out the code it's going to install aws cdk the requirements all that good stuff so let's go ahead and wait for this to be done here okay and as we can see everything has deployed successfully we got this beautiful green little check mark here so let's go ahead and take a look at what actually happened so first it configured the aws credentials here for us with the access key the seeker key and the aws region next it installed npm so it went through you know the ubuntu aptitude package manager and it installed npm for us next we went ahead and we installed the aws cdk with the npn package manager as we can see right here we then went ahead and installed the requirements as you can see it's bringing down aws cdk and then we have the synthesize here so this puts the application deployment into uh yaml format and syntax and then finally it does the deployment here for us so if you're interested in using cdk just like you know infrastructures code like you would with terraform or something and you want to deploy it via github actions you absolutely can i hope this video was helpful for you and i'm definitely looking forward to seeing you on the next one thanks a lot
Info
Channel: Michael Levan
Views: 1,062
Rating: undefined out of 5
Keywords: aws, amazon web services, cloud development kit, CDK, infrastructure-as-code, infrastructure-as-software, python, terraform, cicd, github, github actions
Id: KCp6BmUGBHc
Channel Id: undefined
Length: 5min 59sec (359 seconds)
Published: Fri Jun 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.