How to create a EC2 Instance? | Amazon Web Services

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in the previous video we saw what is Amazon Web Services in this video we are going to create a ec2 instance and log into that ec2 virtual machine from her laptop basically from my laptop the prerequisite for that is creation of an AWS account inside aws.amazon.com you just need to give your credit card information initially two rupees will be detected if you are from India and later on this two rupees will be refunded back this is just to validate the credit card and the authenticity of our information so I'll be showing you how we can log-in to AWS and create a ec2 instance and automatically log in to that particular ec2 instance from the laptop using the SSH command so let's see how we can do that in this particular video rinse the bell icon on the YouTube app and never miss any update from tech primers this is the AWS management console you can log into the console when you are in aws.amazon.com so it by default will show you the login to console option you can log into the console option you can notice that there is a sign into the console you can log into the console in order to see this particular webpage and you have lots of options as I mentioned in the previous video you would have seen lots of different options which I showed from these services let's see the major ones in this series so in this particular video I am going to show you how you can create a ec2 instance in order to create a ec2 instance we have to go to services and go to this ec2 option ec2 is nothing but elastic computing cloud so let me click on this easy to option so once you click on the ec2 option it takes you to a dashboard so this is the ec2 dashboard where it shows all the different ec2 instances and the regions where they are present currently if you see there is zero ec2 instance running in this particular data center so currently I am in the data center North Virginia and there is nothing here some time back I had created a ec2 instance in another data center and I was just trying out stuff so I will just show you that so if I show if I go to 0 running instances it shows the see if you see here I had terminated one easy to instance which is present in a different data center so this data center is in Ohio I have now selected North Virginia so that I can show you that you can create different easy two instances in different data centers and you can individually login to them separately so let's click on the launch instance so this launch instance option is going to set up the whole ec2 instance for us and I wanted a Linux machine to be installed in this particular instance so basically what I am doing here now is I'm just buying a machine so I'm just buying a machine dedicated for our login so that's what I am going to do now in order to do that you can click on that launch instance option and it will take you to the series of steps let's see what are these steps so we are going to select the image which needs to be installed in that particular server which we are going to buy and the image is called Amazon machine image which can be installed in the Amazon infrastructure so I'm going to use the Ubuntu version I wanted a one two server you have Red Hat server you have Amazon Linux as well and there are various other options for example windows options as well so you can even create a ec2 instance which is windows-based so you can even have Microsoft Windows Server there I now wanted her you want to server so I am just selecting this particular option and it is eligible for free so the next option is the instance type now that we have selected what image needs to be instant basically what oh s needs to be installed now I need to provide what is the memory or the configuration for this particular ec2 instance I am going to use the default one for the free tire eligible so it is going to be g/b and one virtual CPU so I'll be selecting that if let's say you are buying it or if you are using it in your company you can go for large or extra-large options which has different memory sizes based on your need you can go there I'm just selecting the micro one so I just selected that already and I'm clicking on the next configure instance detail option so this takes to me to the next step which says configure the number of instances you need I know need only one instance if you need more instances you can just scale it here I'm just going to say I need only one instance and I'm going not going to change any other option here so let's not change any other option if you are having more customized requirements then you can come here and then assign roles to each and every instance so right now if you see here there is no role assigned so you can create a security group and then you can assign roles to the instances separately I'm not going to do that now let's go to the next option the next option is choosing the storage so now we bought a machine we bought the we got the image so we have mentioned all these we also mentioned how many instances we wanted now we can mention what type of storage we need for that particular machine so by default it provides the SSD so I'm just going to say ok and it provides 8 gig of space if you want more space you can just do that so if you see free tire eligible customers can get to 30 gig space or magnetic storage so I'll just give a GB because I don't need much there right now we are just going to do basic stuff right so I'll just keep it as such you can even add more volumes if you need you can add more volumes if you like we're in the same host or the instance now let's go to the next option the next option is adding tags so these tags are nothing but you can identify ec2 instances based on tags if you have more ec2 instances in your data center you can tag these with a name and then you can identify so you can have different key value pairs which can be provided I'm just going to use a common one which people use which is nothing but the name and I'm going to call it ec2 instance underscore two because I already had created one ec2 instance in a different data center which I showed you just for my reference I am just going it going to name it as two so that I know there is already a different ec2 instance in a different data center so I'll just say next now this shows up the security group this is how you can control the accessibility for your virtual machine you can have different types of connections controlled here so if you had worked on access control routes for your WebSphere or Tomcat or any spring security based application you provide security for your application right so this is nothing but security party host you can provide security at different levels for your hosts so there are different types of security rules you can say I want only ssh traffic to be enabled or I want only HTTP traffic to be enabled or something similar so you can control the ec2 instances based on these type of security types I'm just going to say all traffic for now so that we don't have any objection and logging in you can just enable SSH if you if you need to login only to the Machine and not do anything else if you need SSH HTTP HTTPS you can individually do that as well but in production people are not suggested to use all traffic but since this is the demo I am just going to use all traffic the next one is the protocol by default it got selected as all because I selected all traffic the port range is complete the source could be from a particular IP we can mention our soaps IP address this will enable the connections only from a particular IP address but I am just going to mention anywhere so that any from anywhere I will be able to log into this particular machine so that's what I'm going to do here I'll just select anywhere and let me give a description for this particular security code I'll just give all traffic so that I can differentiate and I what kind of security group this particular easy to instance has let me go to the next option which is the last and the final reviewing place where you can edit the options which we have selected previously I can just see what all options we have selected here I'm just going to say proceed because we just went through this now right so this is the important step in the ec2 instance creation there the password is going to be given to us so this is not a password as such but this is a key value fare file so Amazon is going to give you a private key and we need to use that by a private key to connect to Amazon every time so we need to secure this file I'm just going to ask Amazon to create a new key file and I'll just name it as ec2 instance underscore 2 because that is the name of my ec2 instance so I'm just going to use a different key value pair file so basically this will generate a key file so I will just say download keeper this will generate a private key and a public key and the private key will be given to us and the public key will be present inside the Amazon instance so I have the key downloaded here so it is present in my downloads option so we'll I'll show you why and when we will use it now the next option is to click on the launch instance so this launch instances is going to create the whole virtual machine right now in front of us based on the configurations which we provided in these steps so I'm just clicking on the launch instance option so this is now creating the instances as we talk and I can go to this particular option it says following instance launches have been initiated let me click on that and see how it how the initialization is progressing and you can notice that the instance state is pending so basically this is getting created currently as we talked all the images are getting built the spaces are getting mounted so literally a Linux machine or a Linux server is getting built right now with the configurations which we provided so let's wait for this particular instance to get completed meanwhile what we can do is I think there is no connection option enabled right so but I will just show you what we can do from this UI so there is an option called actions and using the actions you can control the instance so for example now if you see the instance is up so you can stop reboot terminate you can do all those stuff here so this is like literally so I don't do anything so this is like literally killing your Linux machine so imagine that you have a deployment manager UI and you are going to be able to stop and start in the next service that is what this is you can even terminate the Machine and later reinstated so terminating the machine will remove all the relevant files which are present inside that particular virtual machine and when you reinstated it will recreate a whole instance with the same configuration which you have provided initially so right now if you see the machine is up and we have our in each instance up and running let's try connecting to this particular machine right I'll click on the connect option once I click on the connect option I get these steps for connecting to the instance so the initial step it says is you can use putty to connect to the Amazon server but I am NOT going to use putty I have by default terminal in my laptop in in OS X I have by default terminal which is exactly similar to pootie if you are using Windows I would suggest you to use putty download putty and then install it right and we already have the certificate file downloaded right the key find the private key file basically so what Amazon suggests has to do is reduce the permission for this particular file to only us so we need to restrict the permission for this particular key file so let's do that right I'll just open the terminal and just say easy to Stearns and see that I have the file here right yeah so I have the file here I need to restrict this particular file to only me so I'll just say chmod 400 and a c2 instance underscore 2 dot p.m. so I have changed the permission for this particular file so nobody else except me can access this file now in order to connect to this machine which we created this is the URL for our machine and in order to connect using SSH I need to use this command so basically I'm using the certificate which is present here and I'm connecting to the machine so I just do SSH - I provide the private key and I provide something called Ubuntu at the Machine name so Ubuntu is the default login which is provided for us so that you can login to the Amazon ec2 instance which we created so it is asking me to say if it is a secure connection and just say yes so this is going to login us into the machine see that we are logged into the machine and let me do a clear so if you see here this is how we are logged in so we are logged in to coupon - username and the directory which we are in is home slash Ubuntu so we are literally logged in to the Amazon server right we are logged in to the ec2 instance which we have created just now so let me do a hostname so if you see here this is how the hostname is you so let's try doing nslookup so I even I didn't try doing nslookup in a looker just to clear you so it shows an IP address this is the IP address and I think in the IP address is mentioned here so I thought it's a different IP address but looks like the host name it comes up with the IP address and it is exactly the same right so this is the external IP address which we are connecting to now let's come back to the console here right so if you want to stop this particular machine you can use the actions and then stop meanwhile let's come back here and you can see that we have access to create file so I'm just going to say I'm just going to create a file called hello dot SH and let's try running a script file right I'm just going to say hello YouTube so usually we do a hello world right so I prefer hello YouTube because YouTube is our primary audience right so I'm just going to create that I will just give some permission for this particular file for now I'll just say 777 and I can run like any other Linux machine I can run all the commands which I know and you can see that I just created a script file and then I did a hello world hello YouTube basically so this is how you can login to the Amazon ec2 instance and you can create stuff you can even install lots of middleware components like if let's say you want Tomcat you can install it with the 8 GB space you can do whatever you want in this particular easy to instance and if let's say you terminate this instance so what happens right so let's try stopping this instance so I will just go to instance and then stop so when I stop this instance the machine gets literally shut down so if you see here already we got a message saying connection has been closed and it just came out this is because Amazon received a stop connection from our UI and then it has shut down the machine so basically this is like shutting down your system or the computer right so that is what happened so and it if you see here it is showing is stopping so let it get completely stopped and let's try restarting again so whatever file we created this file should stay there because we just shut down the machine right so we did not terminate the machine terminating a machine will remove all the files inside that particular instance which was there but when you do a shutdown and start it should not Glade files in that particular easy to instance so let's wait for this guy to shut down completely basically stop yeah it is stopped completely now let's try starting it again and then let's try logging in so that we can see what is the state of the server now you can even use these options which are present here if you see here there are status checks there are monitoring options here which can show you what is happening in these servers so right now it's just new server right so there is nothing here but maybe we can see once we have it running for a while and you can see the tag here whatever tags we have added we can see it here you can add more number of tags you can tag it as a particular application name or anything which you need so these are like variables which we will be using when you want to identify a server so right now the server is back again it's showing running let's try running it connecting again with our SSH key now it should directly take us to the machine clear you so now we are able to connect it I think we have to use the command every time so I just say yes so we are able to login now let's see if our file is present here yep we have the same file and let's try running that hello YouTube yeah so her file stays there now let's try terminating this particular machine right let's try hitting it and let's see what happens if you do a reboot it will just do a stop and start it's like restarting our mobile right so let's try terminating this I will just try terminating and let's see what happens after termination because we had a file created in this machine right and let's see what happens to this particular file whether the particular file stays there or whether it is getting removed yeah the instance now shows as terminated state if you notice here we are not able to start the instance we are not able to stop neither we are not able to we are able to do anything we just can't see the system log at max so what happened there that's all it shows I don't think there is anything which is useful for us it's just showing what happened inside the machine yeah it's just powered on now how do we reinstate this machine so you will have to create a new instance based on a template we did not create any template so we will have to create a new instance which is not ideal right so which is which cannot be done so we will have to go to the launch instance option and then select again the new instance and then use it right so this is how you can create an easy-to instance and you can stop and start so once you terminate a instance you cannot login to that particular instance and you cannot recover the files so if you are going to recreate instances every now and then you can create the template you can create a launch template and then you can create that every time so we can create a common template you can throw out all the details here and then you can just click a button and the ec2 instances will be created on the fly so this is how you can use Amazon AWS management console to create a easy-to instance and log in from our terminal from our laptop I hope you found this interesting in the next video we will be are trying to deploy a web service into the ec2 instance so we just created I see two instance in this particular video in the next video we will try to deploy a spring boot application into this particular instance which we created that's it for this particular video if you liked the video go ahead and like it if you haven't subscribed to the channel go ahead and subscribe to it wait you again in the next video thank you very much [Music]
Info
Channel: Tech Primers
Views: 21,443
Rating: undefined out of 5
Keywords: techprimers, tech primers, ec2 aws, ec2 aws tutorial, amazon ec2, amazon web services ec2 instance, amazon ec2 instance tutorial, ec2 tutorial, configure ec2 instance, amazon ec2 example, ec2 aws example, aws ec2 instance creation, aws ec2 instance, aws ec2 instance types, amazon web services tutorial for beginners, amazon web services, amazon web services tutorial, aws ec2 interview questions, aws ec2 demo, how to create ec2 instance in aws
Id: xYEvbneAhk4
Channel Id: undefined
Length: 21min 9sec (1269 seconds)
Published: Thu Mar 22 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.