Today, we will explore how to set up an Amazon EC2 Linux instance (micro) in the cloud and get it running successfully. We will also see how to attach an elastic IP to our instance and discuss some points/facts that we need to be aware of. This is my second article in the Amazon tutorials series. I hope you have already signed up with the AWS free usage tier and are ready to claim your free server.
What Is EC2 Regions?
Well, understanding the term ‘region’ is vital and important as an AWS user. Amazon has its data centers distributed in various areas around the world. Each key area is referred to as a region. Regions share some EC2 resources, and some don’t. Depending on the region, the price also varies. Please check the ec2 pricing section for more details. However, as this tutorial series will walk you through the free trial, there is no need to worry about region selection. It’s enough to get only familiar with it.
Create A New Amazon EC2 Linux Instance:
First, Log in to your AWS console and select the EC2 service console. After you reach the EC2 dashboard, you should see a page like as follows, which summarizes your EC2 statistics like the number of instances/elastic IP/EBS volume, service status, etc:
Though you can launch a new instance right from this dashboard page, let’s have a look at the instances page without any instances running, as well. Click on the ‘instances’ link on the left menu, and you will reach a window which should look like as follows:
Now click on the ‘launch instance’ button, and it will bring a new instance launch window with three different ‘wizard’ options to assist you: classic, quick launch and AWS marketplace as follows:
The quick launch will show minimal options, and the AWS marketplace is for those who want to buy environment-ready instances. As we learn to set up the environment ourselves, we will use the classic wizard to explore all possible options. Let’s select it(if not already) and click next. You will see a request instance wizard as follows:
Here, you can choose what type of instance you wish to launch with all available operating system(32/64 bit) options. Note that not all instance types are under the free tier. Only the ones with a star mark next to them. In my case, I chose an instance of Ubuntu Server 12.04 LTS(64-bit). You can do so or a different one. Then, you will be taken to the next stage to enter ‘instance details’ as follows:
Now this stage has few sub stages. Firstly, you will get a simple window for entering key-value pairs. You can simply add the ‘name’ key with your desired value (optional) and move to the next sub-stage:
Here, you will be able to select number of instances you want to launch, instance type availability zone etc. You will have the option to request spot instances here as well. Let’s select one micro instance with no preference for availability zone(one will be assigned automatically) and forward to the next sub stage for storage configuration:
For Linux micro instance, it’s provided with default 8GB root storage (for windows storage, it’s bigger though), which is enough to get started. We don’t need to configure EBS storage now; we will do it later. Now let’s move to the next sub-stage of advanced options:
As beginners, we can skip it easily. However, you can use the option for ‘prevent accidental termination of instance’ and ‘shutdown’ behaviour if you need it at all. Let’s move to the next stage of security/firewall configuration:
Here, you can select an existing security group or create a new one. If you have no intention of using more than one instance at all or want to use similar security for more than one instance, then it’s easy to just select the ‘default’ group given automatically. You can change/modify the security group anytime, so there is no worry at all if you are not sure what to do at this moment. After completing the section, we are done with all options. In the last stage, you will be shown the full summary configuration for review:
After you complete the review and submit it, it will take a while to get the instance running, and you will now see a new look of the instances page:
Congratulation! You made it. We now have an active Amazon ec2 Linux instance up and running.
Start/Stop/Terminate/Rebooting Of An Instance:
These operations are relatively easy to perform. You need to check the instance(s) you want to be operated and use the ‘Actions’ drop-down ‘Actions’ commands to do so. Right-clicking on an instance will work as well. Remember, free tiers are counted as hours utilized, not by the number of instances. So, you can have multiple ec2 instances up and running under the AWS free tier as long as you don’t overflow per month’s allowed hours. Keeping some instances stopped will help you a lot in this case :). Also, Amazon has an advance option that terminates an instance upon shutdown (see step 9 above). So, be careful whether you have this setting or not and use it accordingly.
Attaching An Elastic IP To an EC2 Instance:
Attaching your EC2 instance to a dedicated IP address is a wise decision. By default, even without an IP, you can access your instance with a DNS name assigned by Amazon randomly. You can connect to your server or access your web application using it as an HTTP URL.
The bad news is that this public DNS name will change over time whenever you stop, run, or reboot your instance. So, it’s not a very good idea, even for development/testing purposes. To get relief, elastic IP came on board. You can also get it free during your free trial time.
To get a new IP, please go to the “NETWORK & SECURITY” -> “Elastic IPs” menu option on the left panel and create the ‘allocate new address’ button. You will be asked to accept a confirmation dialogue. As soon as you receive it, a new available IP will be shown on the list. Now, check the IP and click the ‘associate address’ option. You will be shown a small dialogue as follows:
Select your desired instance(if you have more than one) and click OK. We are done! You can now access/recognize your cloud server with this dedicated IP.
References:
As I said before, Amazon has good documentation for its services. Please read their documentation for launching an instance if you have any confusion about any of this article’s sections. Still, have a question in mind? Feel free to ask here by commenting. Also, stay tuned for the next post about working with EC2 security groups and connecting to your EC2 instance.
Subscribe to get the latest posts sent to your email.
About Rana Ahsan
Rana Ahsan is a seasoned software engineer and technology leader specialized in distributed systems and software architecture. With a Master’s in Software Engineering from Concordia University, his experience spans leading scalable architecture at Coursera and TopHat, contributing to open-source projects. This blog, CodeSamplez.com, showcases his passion for sharing practical insights on programming and distributed systems concepts and help educate others. Github | X | LinkedIn
Leave a Reply