How to Launch an EC2 Instance

How to Launch an EC2 Instance

Step by step explanation on how to make your first EC2 instance up and running.

3 THINGS TO CONSIDER BEFORE LAUNCHING AN EC2 INSTANCE:

  1. Choose the ideal instance type: economy, memory, storage, or network? It’s ideal to consider your priorities in your project and decide for the right instance type.
  2. Store your key pair in a secure device: you will generate a key pair during instance launch. Make sure to keep it, you will use it later to connect to your instance.
  3. Make use of security groups, spot instances and user data: As a further knowledge, these details can grant you additional security, save money and time.

7 QUICK STEPS TO LAUNCH AN EC2 INSTANCE:

  1. Select your preferred region, navigate to EC2 page, click Launch Instance
  2. Choose your Amazon Machine Image: free tier eligible Amazon Linux 2 AMI is an ideal option
  3. Choose your instance type: t2.micro is a free-tier, ideal option
  4. Create a key pair, store it securely in your device. You will use it later to connect to your instance
  5. Configure your network settings: You can keep it as is: default-vpc, no preference subnet, ssh allowed from anywhere
  6. Configure storage: you can keep it as is. 8gb is ideal, you have free-tier capacity up to 30gb a month.
  7. Set the number of instances you want to create: one EC2 instance is good for the start. Click launch instance.

What is AWS EC2? What Can I Do With EC2?

You can use EC2 to deploy, publish your applications on the web. If you develop some useful applications at your localhost, EC2 is your to-go-resource. It’s easy to launch, flexible to choose any operating system and allows you to interact with different tools in AWS to strengthen your application.

Furthermore, you can also generate virtual devices at EC2 and have a Mac/Windows/Linux device you use from time to time. You can set regular backup operations for your current projects on the web. You can trigger additional activities with EC2 following events (e.g. send a welcome e-mail to a subscribed user).

EC2 comes up with countless features that is bringing cloud experience to another level.

3 Alternative Methods to Launch an EC2 Instance

  1. You can use an Infrastructure-as-a-Code (IaaC) template: most convenient and efficient, however challenging for first attempts.
  2. You can use AWS command line interface (AWS CLI): more efficient, however still not ideal for the first experience.
  3. You can use AWS console: very easy, visually welcoming, great option to capture details at the beginning.

Considering the fact, for this time we will follow creation of an EC2 instance via AWS console step by step.

EC2 Instance Launch- Explained in Details

How to choose the right EC2 instance type?

Before creating an instance, there are a few key details that are worth mentioning. Choosing the right instance type is the first important detail. Each instance type has its own capacity when it comes to storage, memory, CPU and network performance.

Doubtless to mention, the greater capacity you require on your instance type, the more you will pay for your instance. However, you also want to offer the best experience to your users once your project goes live.

Click here to learn more about instance types of AWS. Assuming this is the first instance you create on AWS, it’s acceptable to continue with the free tier eligible option. Yet make sure it’s on your to-learn-list to figure which instance type is cost-efficient for your project in future. However, for simplicity, we will pursue launching a free-tier EC2 instance at this thread.

What is the use of key pair on EC2?

After launching, it will be crucial to connect to your instance directly from your device, in order to upload your project, test your connectivity or more. Key pair is used to connect to your EC2 instance directly from your device, outside the console.

You have to either generate a key pair, or choose an existing one if any, while you are launching your instance. Make sure you keep your key pair securely stored. Follow this official guide to find out how to connect to your EC2 instance with use of your key pair.

How can I make my EC2 instance more efficient?

With limitless flexibilities becoming available at AWS, a few details can be worth mentioning at the beginning. Security groups are an important part of configuration, to ensure connectivity and security. You can grant access to your EC2 instance from external resources by defining them at the security group. You can limit the traffic that is incoming or outgoing to your instance. You can define it by connection protocol (TCP/IP, SSH, HTTP etc.) and you can define it by IP address (you can limit access to your personal device, or to a particular IP address range).Following, spot instances can reward you a great economy, especially if your application is not performance sensitive. Suppose you are handling a backup work, or a registration form that can tolerate an hour or two delay.

Spot instances will provide you the performance you need, whenever it is available in the market. The only difference is you will pay much less for the same performance you receive from AWS.

Finally user data is valuable to consider in EC2 launching process. Any type of instance you decide to build, it will be necessary to install some supplementary software (load balancer, content management system, config tools etc.). A manual, time-consuming method would be to connect to your instance once it’s launched, type in command line one by one, all the software that needs to be installed. User data is an alternative approach, helps you to automatically install all required software with launch of your instance. Especially in repetitive jobs, user data can save you tons of time that is easy to learn and implement.

1- Select your preferred region, navigate to EC2 page, click Launch Instance

It’s ideal to select the region nearest to your end users, or to yourself. If your audience is not covered by one region, feel free to choose the most dominant one and you can overcome the latency by connecting your EC2 instance to Amazon Cloudfront later.

Select your region at right top of the console. Then type EC2 to search bar and navigate to the page.

You will see launch instance button at left bottom of your EC2 dashboard.

2- Choose your Amazon Machine Image

Name your EC2 instance anything you prefer. To build an EC2 instance, Amazon provides you many templates that are used frequently in the market, these are called Amazon Machine Images. Depending on your need, feel free to choose the one that suits you. For starter, it’s ideal to go with Amazon Linux 2 AMI, since it’s free tier eligible and provides latest features in development.

3- Choose your instance type

Name your EC2 instance anything you prefer. To build an EC2 instance, Amazon provides you many templates that are used frequently in the market, these are called Amazon Machine Images. Depending on your need, feel free to choose the one that suits you. For starter, it’s ideal to go with Amazon Linux 2 AMI, since it’s free tier eligible and provides latest features in development.

4- Create a key pair, store it securely in your device

If you keep key pair field is left blank, no key pair will be generated, which makes your EC2 instance open to the entire web. For security reasons, this is strongly not recommended. If a key pair is generated earlier, it will appear in the box as shown below.

Since this is your first instance launch, it is assumed you need to create a key pair. Once you click “create new key pair” you will need to name your key pair (you can name it anything you want), keep key pair type as RSA.

For key file format, choose .pem if you are a Linux/Macbook user and choose .ppk if you are a Windows user. Once you click “create key pair”, the key pair file will be automatically downloaded to your device. Make sure you keep it secure to use it later for connection.

5- Configure your network settings

As soon as you create a key pair in the previous step, you can keep these settings as is. However, it’s ideal to examine the impact of default settings for the use. When your instance is launched in default VPC, it provides a public subnet, therefore a public accessibility to your instance.

However, it’s possible to launch your instance in a new VPC with private subnet for excluding accessibility. Also as stated earlier, a newly created security group will grant connectivity to your instance in default settings.

6- Configure storage

Here you are expected to connect an Elastic Block Storage (EBS) volume on your instance, to handle the storage requirement needed for your instance. AWS offers 30GB use of EBS every month to its free tier users. 8GB will be more than enough for your first instance, however feel free to adjust the number according to your needs.

7- Set the number of instances you want to create

Finally, at the right side of the screen, you can multiply the number of instances you want to create. When multiple number of instances needed in everyday use, it’s more common to use EC2 launch templates, which define all details mentioned and even more, then can be selected for quick creation.

Additionally, a certain number of running EC2 instances are secured with use of AWS Auto Scaling, which regularly checks if your instances are running and generates a new one to make sure you have enough running instances.

As you launch your first instance, you can check your instances back from the EC2 dashboard. For less than a minute, you may need to wait the “pending” state for AWS to fully launch your instance.

Once your instance is at “running” state, you can connect to it and start your development process.