Hosting Your Resume on AWS EC2 with a CI/CD Setup Using GitHub Actions | AWS Project Demo

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone welcome back to my channel among kin cloud in this video we are trying to host our resume on AWS ec2 instance with a CI CD setup using GitHub actions for this you have four steps first one is to create an ec2 instance and download the key pair second one is to create the secret in your repository third one is to add your GitHub action workflow and the fourth step is to check how it works right so I have documented all the things on my blog so this is my blogging site so you can visit this one and I'll make sure to provide the link to this in the description box below so whatever the code that I'm using for this particular video is well documented on this particular repository I will also make sure to provide the link to this repository in the description box below you can check that out [Music] okay so the first step would be to create an ec2 instance so for that I have logged in to my AWS console and let me go ahead and create an ec2 instance to do that I'll click on ec2 now I'll click on launch instance and I'll click on launch instance again and I will say web server or resume hyphen server you can give whatever the name that you want I'm gonna select Ubuntu and instance type T2 micro is good enough so I'm leaving it as default key pair I'm gonna create a new keypad I'll click on create new and I'll say resume KP KPS and keypad and I'll leave that as dot p e m and I'll click on create keypad and it will automatically download the keypad so keep this Keeper in a secured place so that you won't miss out on this right so this is very important if you do not have this you are easy to instance will not work okay so I'll close this one now I am placing this ec2 instance in the default VPC so I will not change anything here and I'm not changing anything on the subnet level also and I'm assigning a public IP Auto assign public IPS enabled by default so I'm good with that and firewall as in security groups I'm gonna select the security group which is already there so I'll click on that and I'll select Linux SG basically I'll show you what is there in this uh you know Linux SG I have allowed SSS and port number 80 and 443 so I'll show you that so after this uh everything looks good and storage is also good 8GB is fine for me so I'll go ahead and click on launch instance so while it launches I will try to show you the security group okay so I'll come to ec2 here and I click on security groups and I'll open Linux SG so if I come down to inbound rules if you see here there are many things that are opened just because I was testing few things but the only things that you need is SSH Port 22 and your 80 and 443 so these are the three things that you need to allow in the inbound rules so these are all the things that you require here okay next let's go to our instances let's see if the instance is running already or not so the status check is still initializing let's give some time for it to get initialized and the status check should be two by two passed okay I'll pause the video for some time and I'll come back once it is ready all right now if you see the status check two by two checks are passed okay now let's see what exactly we are trying to do right so if I go back to my GitHub repository I have two files one is index.html where I have the index document here and I also have some styling okay so let me show you how exactly the resume looks okay so this is a simple site that we have right so just in in the format of a resume okay so I have summary here I have skills I have experience all these things are added if you want to enhance this this is not a portfolio website remember this this is exactly the same as your resume right so if you want to add a picture here and do whatever you want you can do that but this is not your portfolio site this is your resume right so in the form of website so this is what we are trying to achieve let's say your name is uh you know we have a web developer role right now but in future you will be transition to software developer so in in that case you have to update this site so how will you do that so and for that you might need a downtime if that wants to be applied on the ec2 instance also in our scenario what happens if you just update the site here on your GitHub page so automatically it will be picked up the changes will be picked and it will be deployed on the ec2 server right sounds cool right so you need not login again and change the code on the ec2 instance we are achieving that using the CI CD process using the GitHub actions okay so that is our main intention now we have created the server and we have also downloaded the key that we already have okay if I go here you see uh my key pair named resume hyphen kp.pm is there in my folder right so I have created a separate folder dot keys and I've stored all my keys there right so I highly recommend you also doing the same thing okay now let's do to the Second Step the Second Step would be to create the secrets in the GitHub for your repository so what are the secrets that you need to create I've also documented the same here you can just refer this and you can add the appropriate content there okay so let's go and do that one by one so the first secret name that we need to create is the easy to underscore SSH underscore key so basically what is this secret secret is basically you are not disclosing what you are trying to what you are having the content instead you are storing it as a secret in the GitHub repository itself okay so first key that we are trying to store is EC to SSH key so if you remember we downloaded the PM key right so that we need to store it as a secret so if you ask me why are we storing that so who will need to login to that ec2 instance on behalf of us we are allowing the GitHub to log in and make changes right for that we need to create a secret and allow the GitHub repository to talk to the ec2 instance okay so let's see how to do that I'll go back to my repository here so remember you need to make this changes on your repository where you are trying to achieve this Okay click on settings here and if you come all the way down you will see something called as secrets and variables if you see there is a drop down click on that you will see actions click on that and here you need to create a new repository secret so I'll just click on that and it'll ask you for the name and the value okay so here I'll place the name sorry I'll place the name as easy to underscore SSH hyphen key here you need to paste the content of that key remember as this is a demo I am showing the key pair what is the value we have but you should never disclose the key pair anywhere right so it is not at all recommended for you to show what what you are storing there okay so I'm gonna open that on my visual studio code and this is how it looks right so let me close this this is how it looks just click Ctrl a control C and go to your repository paste the exact same content do not remove anything do not add extra space or something right so just copy paste it do not show this to anyone but as this is just for a demonstration I'm gonna show you and I will be deleting it after this demonstration okay I'll just click on ADD secret now the secret will be added okay so the next thing that we need let's go back host underscore DNS what is host underscore DNS every ec2 instance will have the public ipv4 DNS so you can just copy this and paste it there right so that is also required right so if you do not have the IEP address how will you log into the ec2 instance right so we need that so I'm gonna create a new repository secret again and I'm gonna use the same name I will tell you why we are using the same name at the end okay so I'll copy the public ipv4 DNS and also paste the same in the secret okay I'll click on ADD Secret that is also done next let's go back to another one so username username it would if you are selecting Ubuntu machine it will always be Ubuntu itself right so I'm gonna go and create a new repository secret here and I'll paste this username and Ubuntu as I told it is always Ubuntu I will show you I'll paste this and I'll click on ADD secret so if you want to verify if you come all the way down yeah here if you see it is mentioned as Ubuntu right so this is what we are using here okay so the next Target directory so as soon as you log in what is the directory that you want to copy the content from the GitHub and place it into the ec2 instance so I'm gonna use home as the directory Target directory okay so I'll just go here and I'll click on another repository secret so I'll give that here and I'll give home so just home right so I'll add the secret so what we did we created all the secrets that are required for a demonstration okay so let's just verify that so in fact it should look something like this so when when you create you should have all the secrets created okay so if you see here we have all those created Next Step would be to create the workflow so I'll tell you what is workflow so you can create that so here is the code I'll just copy that and this is the path that you need to use so I'll go back to the repository so workflow is just like your CI CD setup for GitHub actions so that would be done using a yaml file so you need to create a yaml file to do that you can just click on ADD file here and click on create new file okay so you need to create a folder structure I'll show you what is that structure looks like so here once you have this is your repo name and here there is an empty location you can paste this whatever we copied for GitHub actions if that needs to work you need to create a special folder directory so that is dot GitHub slash workflows and the name of the yaml file that you are trying to create so I am using GitHub actions ec2 dot EML okay so now here you need to paste the content that you have so now what is the content that you need to paste here so let me go back to my blog site and I'll explain what we are trying to achieve here so the final workflow dot yaml will look just like this so what we are trying to do we are trying trying to trigger a deployment only when the code changes are made to the main branch so in GitHub you can create multiple branches when there is a code change occurs on the main branch only then push the changes to your ec2 instance so how it is going to push the changes it needs to have the secrets created right so the or it needs to have the server information so where it is so we have stored that already in the secret and we are trying to read the secret in this particular para if you see here SSH private key we are getting it from this secret remote host we are getting it here user Ubuntu Target directory is your home right so that we are getting it here from the steps I have defined a parameter called step and here we are mentioning these parameters okay next after getting all the contents from your GitHub repository whatever the files we had index.html CSS readme all those files will be deployed into your ec2 instance home directory because that is our Target directory so after that next we will execute some Linux commands so this is this is the step that is going to do so what we are trying to do we are using the same secrets we are logging in we are using the same username we are using the same key and here we are trying to update the system first and install Apache 2. so Apache Apache 2 will be installed then we are starting the Apache 2 and we are enabling the Apache 2 in these two commands next what we are trying to do we are changing the directory to the home directory why home directory because that is where we are having all our files present right so we switch to home directory and from home directory we are moving all the files from there to this particular location so what is this location this location is location where we have the default HTML page of apache2 so that is where your content will be displayed on the site so this is where you can access all your website content right so for that we are moving the content from home directory to this particular location right so it seems simple but if you try to achieve this right so that will give you a whole lot of satisfaction uh from you right so just what you need to do is you can just copy this everything else is same okay I'll copy this and I'll paste it here okay so make sure you are using the same name in convention as that of me if not it will fail if even if it fails right to be trying to debug is another you know level of satisfaction that will get okay so now I'll just click on Commit changes and I'll hit commit changes so without even logging into your ec2 instance all the data will be taken and it will be pushed into your ec2 instance and by using your ec2 instances public ipv4 address you will be able to access the site okay now let's go ahead and test if it is working fine or not so let me go to the repository and if you click on actions you will see whatever it is happening if you see here automatically it triggered the job and it is creating the GitHub actions ec2.yaml the first step is going on if you click on this if you you will get the more information so what is trying what it is doing what and all we have configured it is working fine not where exactly it failed all the things you will get to know once you go into that section is any failure it will give you a red mark here saying that it failed if it passes it you will give a it will give a green tick so that it passed right so let me go back and show you so if you see here uh the push has been done to the ec2 instance and it is showing the green tick so let's go to our ec2 instance grab our public ipv for address or the public IP DNS and I'll paste it on my browser okay so you should be seeing the content that you have already deployed on your GitHub repository right cool right so without even logging into the server we were able to see this now let's make another interesting thing so let's say my name is not John Doe so instead what I'll do I'll go ahead and change the name to a Monken Cloud right so or whatever the things let's say your resume looks like this now but in future your skills are added so in that case you need to edit this site right so for that you can go back to your GitHub site let's say you are trying to edit index.html I'll click on edit here uh I'll just say I'll remove this one and I'll just add a Monk in Cloud okay so that is all I need I'll just click on Commit changes and I'll hit commit changes again so I made the code changes on Main repository right so main branch so what happens automatically it will pick up the changes and it will start deploying again so if you want to verify go to actions again and if you see here update index.html is happening right now so it was pushed by me and it is still in progress you will see the status also here now if you see there is a green tick available that means your update has been successfully done now let me go back to my site and I'll just refresh the site you should be seeing the content that you edited right so this is really cool if you want to enhance this one you can go ahead and add your own DNS here if you see here I'm using Amazon public ipv4 DNS but if you want to add you can add your own pop DNS for example resume.yourname.com or something like that right so that also you can do and you can also install SSH certificate SSL certificates which are freely available for you or you can also use AWS certificates also right so that is for your uh you know understanding and you can do more research on that and you can work on this I hope you learned something new in this project so although it was a very simple project but the process of learning this one is a you know amazing I even I learned a lot of things I didn't know how to run the commands using this particular part so I explored this on myself and I got to know how it works so usually in the sites and all they will mention what updating this command and all but installing something and you know doing something like this is really amazing so I hope you enjoyed learning along with me if you are liking the content that I'm creating please consider subscribing and share it among your friends thank you and I will see you in the next one with another project until then bye bye [Music] foreign
Info
Channel: A Monk in Cloud ☁️
Views: 13,750
Rating: undefined out of 5
Keywords: #AWS, #LearnAWSforFree, #Free, #FreeResources, #2022, #AWSCommunityBuilderProgram, #Community, #Server, #EC2, #Instance, #EC2_Instance, #Demo, #Commands, #LearnAWS, #AWSCommunityBuilder, #AWSCertified, #Automation, #SnapshotCreation, #AWSEC2Instance, #CompleteTutorial, #LiveDemo, #ProjectBasedLearning, #ClearAWSInterview, #InterviewPreparation, #OnlineLearning, #SelfThoughtLearner, #Opportunity, #DevOps, #ITCareer, #DevOpsRoles, #Jobs, #India, #AWSDevops, #Happy, #AWSAccount, #TrainingOnAWS, #CloudComputing, #Tutorial, #AWSDemo
Id: YBjrZZMXNe8
Channel Id: undefined
Length: 19min 47sec (1187 seconds)
Published: Tue Jun 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.