> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating New EC2 Instance using Snapshot

> Hands-on lab · 30m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/creating-new-ec2-instance-using-snapshot" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab Details

1. This lab walks you through creation of an snapshot of EC2 instance and how to launch a new EC2 instance using the AMI of that snapshot.
2. Duration: **30 minutes**
3. AWS Region: **US East (N. Virginia) us-east-1**

### Introduction

#### What is a Snapshot?

* A snapshot is defined as a point-in-time copy of your EBS Volume, which is copied to Amazon Simple Storage Service (Amazon S3).
* EBS Volume stands for Elastic Block Store. It's a service that provides persistent block-level storage for Amazon EC2.
* These snapshots are incremental copies of data, i.e., only unique blocks of EBS volume data that have changed since the last snapshot was taken.
* Only the new and modified blocks from the last snapshot are taken, so it's called "**incremental copy**" of data.
* Snapshots contains all the information needed to restore your data starting from the moment it's created.
* Snapshots are chained together. Due to which, we will be able to properly restore the volumes when needed.
* Snapshots can be deleted.
* When a snapshot is initiated, AWS reads each block, determines if there's any data on the block, and then includes it.
* Any data written to the volume after the snapshot creation started is included in the EBS Snapshot, even if the snapshot remains in a "pending" state.
* Multi-Volume snapshots allow you to take exact point-in-time, data coordinated, and crash-consistent snapshots across multiple EBS volumes attached to an EC2 instance.
* At the time of snapshot creation, you do not need to stop the instance. Because of this, they are automatically taken across multiple EBS volumes. Just like AMIs, you can share snapshots across AWS accounts and regions by modifying its access permissions.
* Taking copies of snapshots is allowed in AWS.
* Snapshots can be copied only when its status is marked "completed".
* Snapshots support EBS Encryption.
* Snapshots of encrypted volumes are automatically encrypted.
* Volumes that are created from un-encrypted snapshots can be encrypted on-the-fly.

**Note - Snapshots can be taken only from EBS volumes, and not Instance Store volumes.**

### Architecture Diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/001.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=fcb72f8f2c61e11d5c74710ffe577fe1" alt="" width="900" height="380" data-path="images/labs/creating-new-ec2-instance-using-snapshot/001.png" />

### Task Details

1. Sign in to AWS Management Console.
2. Launch an EC2 instance.
3. Create a snapshot from the root volume of your instance.
4. Create an AMI from the snapshot.
5. Launch an EC2 instance using newly created AMI.
6. Test the new EC2 instance created from AMI.

### Launching Lab Environment

1. To launch the lab environment, Click on the **Start Lab** button.
2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
3. Once the Lab is started, you will be provided with **IAM user name**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

> **Note** : You can only start one lab at any given time

## Lab guide

### Lab Steps

#### Task 1: Sign in to AWS Management Console

1. Click on the **Open Console** button, and you will get redirected to AWS Console in a new browser tab.
2. On the AWS sign-in page,

   * Leave the Account ID as default. Never edit/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
   * Now copy your **User Name** and **Password** in the Lab Console to the **IAM Username and Password** in AWS Console and click on the **Sign in** button.
3. Once Signed In to the AWS Management Console, Make the default AWS Region as **US East (N. Virginia) us-east-1.**

#### Task 2 : Launch an EC2 Instance

1. Make sure you are in the **US East (N. Virginia) us-east-1** Region.
2. Navigate to **Services** menu in the top, then click on **EC2** in the **Compute** section.
3. Click on **Instances** from the left side bar and then click on **Launch Instances**
4. Name : Enter ***MyEC2Server***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/002.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=e9ea3c8b1e442e9d38856600e1ed9f43" alt="" width="975" height="190" data-path="images/labs/creating-new-ec2-instance-using-snapshot/002.png" />

5. **For Amazon Machine Image (AMI):** Search for **Amazon Linux 2023 kernel-6.1 AMI** in the search box and click on the **Select** button.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/003.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=295fedccc20d96946db9766e51defe1a" alt="" width="1179" height="609" data-path="images/labs/creating-new-ec2-instance-using-snapshot/003.png" />

6. **For Instance Type:** select ***t2.micro***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/004.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=3b949141e2f3106e207bc11ee71da5b1" alt="" width="971" height="260" data-path="images/labs/creating-new-ec2-instance-using-snapshot/004.png" />

7. **For Key pair:** Select **Create a new key pair** Button

   * Key pair name: **WhizKey**
   * Key pair type: **RSA**
   * Private key file format: **.pem**
8. Select **Create key pair** Button.
9. In Network Settings Click on **Edit**:

* Auto-assign public IP: **Enable**
* Select **Create new Security group**
* Security group name : Enter ***MyEC2Server\_SG***
* Description : Enter ***Security Group to allow traffic to EC2***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/005.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=a7f29c85dcc7fcd1e14d27b8f7afc284" alt="" width="975" height="472" data-path="images/labs/creating-new-ec2-instance-using-snapshot/005.png" />

10. Check **Allow SSH from** and Select **Anywhere** from dropdown

* To add **SSH**,

  * Choose Type: **SSH**
  * Source: Select **Anywhere**
* For **HTTP,** Click on **Add security group rule**

  * Choose Type: **HTTP**
  * Source:  Select **Anywhere**

11. Click on **Advanced Details** and under the **User data:** section, enter the following script to create an HTML page served by an Apache httpd web server.

```
#!/bin/bash
sudo dnf update -y
sudo dnf install httpd -y
echo "<html><h1> Welcome to IP Lab Portal Server 1 </h1></html>" > /var/www/html/index.html
sudo systemctl start httpd
sudo systemctl enable httpd
```

12. Keep Rest thing Default and Click on **Launch Instance** Button.
13. Select **View all Instances** to View Instance you Created
14. **Launch Status:** Your instances are now launching, Navigate to **Instances** page from left menu and wait the status of the EC2 Instance changes to running and health check status changes to **2/2 checks passed** .

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/006.jpg?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=61cf2903b990ebce865538f1c3e21e8c" alt="" width="1225" height="108" data-path="images/labs/creating-new-ec2-instance-using-snapshot/006.jpg" />

15. Select the Instance and Copy the **Public IPv4 Address**
16. To test if the HTML page published, copy the Public IP address and run it on the browser.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/007.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=4d8c79cd62b2ba0e743401c493d0acbe" alt="" width="458" height="109" data-path="images/labs/creating-new-ec2-instance-using-snapshot/007.png" />

#### Task 3 : Create a Snapshot of EC2 Instance

1. Navigate to **Snapshots** section under **Elastic Block Store** from the left menu.
2. Click on **Create Snapshot** button.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/008.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=ca6d3fa04130f2ec6c78d977639545e2" alt="" width="2832" height="526" data-path="images/labs/creating-new-ec2-instance-using-snapshot/008.png" />
3. In the Create snapshot page, fill the details below.

* Resource type: Select **Instance**
* Instance ID: Select **MyEC2Server** from the drop-down menu.
* Description : Enter ***MyEC2Snapshot***
* Encrypted: Leave as it is.
* Tags Click on **Add Tags** button

  * Key : Enter ***Name***
  * Value : Enter ***MyEC2Snapshot***

    <img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/009.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=3d8a5297ca5c343bf0944caba4fcee89" alt="" width="2864" height="618" data-path="images/labs/creating-new-ec2-instance-using-snapshot/009.png" />

4. Once the snapshot creation is completed, the status will change to **completed**.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/010.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=9d81d607de570a5f12a0f7db9da987df" alt="" width="986" height="112" data-path="images/labs/creating-new-ec2-instance-using-snapshot/010.png" />

#### Task 4 : Create an AMI from the Snapshot

1. Select the Snapshot that you have created.

2. Click on the **Action** button on top right menu and select **Create image from snapshot**.

3. A pop-up window will show up. Provide the details as mentioned below to configure your AMI:

   * Name: Enter ***MyEC2AMI***
   * Description: Enter ***My EC2 AMI***
   * Leave other settings as default.
   * Click on **Create Image** button.

4. Navigate to **AMIs** under **IMAGES** in the left menu to see the newly created AMI.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/011.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=044e7d60ddd21e3fae4091629cdec960" alt="" width="899" height="114" data-path="images/labs/creating-new-ec2-instance-using-snapshot/011.png" />

#### Task 5 : Launch an EC2 Instance using newly created AMI

1. Select the AMI that you have created and click on the **Launch Instance from AMI** button to launch a new instance.
2. Name : Enter ***MyEC2AMIServer***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/012.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=bbcb6f96b360b0b21966729ff5180223" alt="" width="970" height="196" data-path="images/labs/creating-new-ec2-instance-using-snapshot/012.png" />

3. **For Instance Type:** select ***t2.micro***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/013.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=4b7083a1b255e67ae5c7eed3d8ab0886" alt="" width="971" height="260" data-path="images/labs/creating-new-ec2-instance-using-snapshot/013.png" />

4. **For Key pair:** Select the key you created previously.
5. In Network Settings :

* Auto-assign public IP: **Enable**
* Select **Select existing security group** and Select the group created earlier

6. Click on **Advanced Details** and under the **User data:** section, enter the following script to create an HTML page served by an Apache httpd web server.

\#!/bin/bash -ex

```python theme={null}
sudo service httpd restart
```

* **Note: After pasting the user data, make sure to remove extra spacing.**

7. Keep Rest thing Default and Click on **Launch Instance** Button.
8. Select **View all Instances** to View Instance you Created
9. **Launch Status:** Your instances are now launching, Navigate to **Instances** page from left menu and wait the status of the EC2 Instance changes to running

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/014.jpg?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=07d5ac33811cc2108ba80f1a4cfa21e0" alt="" width="1227" height="146" data-path="images/labs/creating-new-ec2-instance-using-snapshot/014.jpg" />

#### Task 6 : Test the new EC2 instance created from AMI

1. Once your new instance status is running, copy its **Public IP**.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/015.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=45695a19b8390839685dad71b63fd39e" alt="" width="712" height="278" data-path="images/labs/creating-new-ec2-instance-using-snapshot/015.png" />

2. Paste it into your browser.
3. You will be able to see the output of **MyEC2AMIServer**  is the same as the one we got from the initial EC2 instance **MyEC2Server**.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/p7IVRSp3uOckIajV/images/labs/creating-new-ec2-instance-using-snapshot/007.png?fit=max&auto=format&n=p7IVRSp3uOckIajV&q=85&s=4d8c79cd62b2ba0e743401c493d0acbe" alt="" width="458" height="109" data-path="images/labs/creating-new-ec2-instance-using-snapshot/007.png" />

> ##### Do You Know ?
>
> When creating an EC2 instance from a snapshot, the snapshot serves as a point-in-time copy of the root volume or additional volumes attached to an existing instance. By utilizing snapshots, you can capture the entire state of the volume, including the operating system, applications, and data.

1. Once the lab steps are completed, please click on the **Validation** button on the right side panel.

### Completion and Conclusion

1. You have successfully launched an EC2 Instance and created a Snapshot from it.
2. You have successfully created an AMI from the Snapshot.
3. You have successfully launched a new EC2 instance from the AMI and tested it.

### End Lab

1. Sign out of AWS Account.
2. You have successfully completed the lab.
3. Once you have completed the steps, click on **End Lab** from your IP Lab Portal and wait till the process gets completed.

## What gets checked

When you press **Check my work**, the platform verifies each of these:

* **Launch an EC2 Instance** — Check whether an EC2 Instance is launched or not.
* **Validate EC2 Instance Type t2.micro** — Check whether the EC2 instance type is t2.micro.
* **Launch EC2 AMI type Amazon Linux** — Check whether the EC2 instance is launched using an Amazon AMI.
* **Create EC2 Snapshot** — Check whether EC2 instance snapshot is created or not
* **Create an EC2 instance AMI** — Check whether the AMI is created from EC2 or not

## Related help

* [FAQs and Troubleshooting](/aws-saa/support/faqs-and-troubleshooting)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.