# How I Successfully Migrated My EC2 Instance to Another AWS Account💡

Migrating an EC2 instance from one AWS account to another might sound like a technical nightmare, but trust me, it’s easier than you think! I recently went through this process, and I’m here to break it down for you in simple steps. Whether you’re a beginner or an experienced AWS user, this guide will help you migrate your EC2 instance smoothly. Let’s dive in!

---

# **Step 1: Stop the EC2 Instance 🫸🛑**

The first step is to **stop the EC2 instance** in the source account. Why?

* Stopping the instance ensures that all data is written to the disk, and no ongoing processes are modifying the filesystem. This guarantees a **consistent snapshot**.
    
* It reduces the risk of corruption or missing data in the AMI (Amazon Machine Image).
    

**How I Did It:**

1. Logged into the **source AWS account**.
    
2. Navigated to the **EC2 Dashboard**.
    
3. Selected the instance I wanted to **migrate**.
    
4. Clicked **Instance State &gt; Stop Instance**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738304764171/a284825f-640a-448d-a449-17d926dd6e12.png align="center")
    

---

# **Step 2: Create an AMI Image 📸**

Once the instance is stopped, the next step is to create an **AMI (Amazon Machine Image)**. An AMI is a template that contains the information required to launch an instance, including the root volume, permissions, and configurations.

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Key Tip:</strong> While creating the AMI, I made sure to <strong>untick the "Reboot" option</strong>. This ensures that the instance remains stopped during the AMI creation process, avoiding any unintended changes.</div>
</div>

**How I Did It:**

1. Selected the stopped instance in the EC2 Dashboard.
    
2. Clicked **Actions &gt; Image and Templates &gt; Create Image**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738305184898/be8be9b6-f82b-4c0e-a267-69331414d76b.png align="center")
    
3. Filled in the details:
    
    * **Name:** Gave the AMI a meaningful name.
        
    * **Description:** Added a brief description for future reference.
        
    * **Unticked the "Reboot" option** to ensure the instance stayed stopped.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738305374786/ff972d60-fff9-4b8d-927b-6ec6be753863.png align="center")
        
4. Clicked **Create Image**.
    

---

# **Step 3: Wait for the AMI to Become Available⚙️**

Creating an AMI can take a few minutes, depending on the size of the instance. Wait for the AMI to reach the **"Available" state** in the **AMIs section** of the EC2 Dashboard.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738305701258/ed516c8f-2f07-4ebc-a182-7fb843a37dd2.png align="center")

---

# **Step 4: Share the AMI with the Destination Account ⏩**

Once the AMI is available, the next step is to **share it with the destination AWS account**. This allows the destination account to access and use the AMI.

**How I Did It:**

1. Went to the **AMIs section** in the EC2 Dashboard.
    
2. Selected the AMI I just created.
    
3. Clicked **Actions &gt; Modify AMI Permissions**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738305839810/8a5bafdc-cbbd-443f-905f-94323b1111d9.png align="center")
    
4. Added the **AWS Account ID** of the destination account.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738305995180/bbcbcb24-590d-4bd6-bcb0-85969aff7142.png align="center")
    
5. Clicked **Save Changes**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738306076257/099ecb43-256e-496e-8de1-aa030fa9cfff.png align="center")
    

---

# **Step 5: Verify the AMI in the Destination Account ✅**

After sharing the AMI, I switched to the **destination AWS account** to verify that the AMI was successfully shared.

**How I Did It:**

1. Logged into the **destination AWS account**.
    
2. Navigated to the **AMIs section** in the EC2 Dashboard.
    
3. Looked for the shared AMI in the **Private image** section.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738306259063/44c6a817-173d-4609-a843-6e3b5eac1395.png align="center")
    

**Success!** The AMI was visible in the destination account, ready to be used.

---

# **Step 6: Copy the AMI to the Destination Account ☕**

To ensure the AMI is fully available in the destination account, I copied it. This step is especially important if the source and destination accounts are in **different AWS regions**.

**How I Did It:**

1. Selected the shared AMI in the destination account.
    
2. Clicked **Actions &gt; Copy AMI**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738306361851/231d27b2-c3b7-4663-8c8b-31de7a960435.png align="center")
    
3. Chose the **destination region** and provided a name for the copied AMI.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738306574566/f409ea6b-c36e-417d-b4dd-616c39b8e43e.png align="center")
    
4. Clicked **Copy AMI**.
    

---

# **Step 7: Launch the Instance from the AMI 🚀**

Finally, it was time to **launch the EC2 instance** in the destination account using the copied AMI.

**How I Did It:**

1. Selected the copied AMI in the **AMIs section**.
    
2. Clicked **Actions &gt; Launch Instance**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738306972898/91e80ff3-85c1-4a51-9a73-9b809adb8e01.png align="center")
    
3. Configured the instance settings:
    
    * **Instance Type:** Chose the appropriate instance type.
        
    * **Network Settings:** Selected the VPC, subnet, and security group.
        
    * **Key Pair:** Associated a key pair for SSH access.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738307056651/c44a178c-0028-45a3-aa19-eb7c3e29eab5.png align="center")
        
4. Clicked **Launch Instance**.
    

---

# **Step 8: Verify and celebrate! ✅🥳**

Once the instance was launched, I logged in to verify that everything was working as expected. I checked:

* **Applications:** Were they running correctly?
    
* **Data:** Was all the data intact?
    
* **Configurations:** Were the settings preserved?
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1738307307844/3a84de5a-f492-4fee-a14d-5a2058f7e8b8.png align="center")
    

**Boom!** The migration was successful, and the instance was up and running in the destination account.

---

# **Pro Tips for a Smooth Migration: 🚀**

1. **Test the Process:** Before migrating a critical instance, test the process with a non-essential instance to ensure everything works.
    
2. **Monitor Costs:** Keep an eye on data transfer and storage costs during the migration.
    
3. **Clean Up:** After the migration, delete the AMI and snapshots from the source account to avoid unnecessary charges.
    

---

# **Conclusion: 🎃**

Migrating an EC2 instance to another AWS account doesn’t have to be complicated. By following these steps stopping the instance, creating an AMI, sharing it, and launching it in the destination account you can ensure a smooth and hassle-free migration.

📌So, what are you waiting for? Start migrating your EC2 instances today and take control of your AWS infrastructure!

---

📬Found this guide helpful? Share it with your team or leave a comment below if you have any questions. Don’t forget to follow for more AWS tips and tricks!

#ec2 #aws #ec2migration # devops #cloud #getintokube #getintokubeblogs
