Creating an Amazon Machine Image (AMI) for your product is a great way to simplify your computing infrastructure. A developer simply launches their software on the AMI along with some configuration variables, and their product is up and running on EC2. With an AMI, you don’t have to build machine images from scratch every time; instead, you start with a pre-built software stack and customize it for your specific needs.
In this post, we will show you how to launch a new instance from an AMI along with some Jenkins configuration variables. Those configuration variables will be used in the next steps to create a customized Amazon Machine Image (AMI) that can then be reused to launch new instances with the same configuration.
What is Elastic Cloud Compute (EC2)?
Elastic-cloud-computing allows users with minimal technical knowledge access large amounts of disk space without having an expensive deal for years worth upfront fees like traditional hosting providers do. You just pay monthly based on what your usage will typically go through each calendar year; if it doesn’t exceed this limit then there’s no extra charge!
- The above picture shows AWS Management Console
- For launching EC2 service, click on the Services drop-down menu as shown in the below figure
- Select EC2 from Compute and you will see the EC2 Dashboard which is shown below
- In the left-hand side of the dashboard, you will see Instances click on that
- After that click on Launch instances
- Now we have to choose Amazon Machine Image (AMI)
- An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the cloud
- Select the Amazon Linux 2 AMI because it is Free tier eligible and you will not occur any charges on your AWS account
- Now we have to select the instance type. So by default t2.micro is selected and we will go with that because that comes under the free tier
- Click on Next: Configure Instance Details
- Here you do not need to do anything just leave all the settings as it is and again Click on Next: Add Storage
- In this step also there is no need to Add Storage and click on Next: Add Tags
- Here we are adding tags. Tagging means giving it a name. So click on Add tag
- Now we will give it a name as shown below
- Click on Next: Configure Security group
- Here we will create a new Security Group name as EC2-SG and keep the description as same and then click on Add rule, from the list select HTTP and select the sources as Anywhere for both SSH and HTTP
- Click on Review and Launch
- After Reviewing click on Launch
- Now you will be asked to create a new key pair or an existing key pair
- Here we will create a new key pair. So click on create a new key pair and give it a name as EC2-key and then click on Download key pair
- After clicking on Download key pair click on Launch instances
NOTE: Don’t forget to download the key pair because once the instance is launched you will not be able to download it.
- Click on View Instances
- Now it will show that the instance is in the pending state but wait for few seconds and you will see that the instance is in running state
- Click on that check box which is beside of instance name and you will see all the Details, Security, Networking and configurations which you have done while creating an instance
- This is the complete overview of how to launch an EC2 instance