> ## Documentation Index
> Fetch the complete documentation index at: https://docs.briankimemia.is-a.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# # Aurora Database Project 🌌

> Welcome to the **Aurora Database Project**! This comprehensive guide is designed to help you create and connect an Aurora MySQL database to an EC2 instance step-by-step. 🚀

# Aurora Database Project 🌌

Welcome to the **Aurora Database Project**! This comprehensive guide is designed to help you create and connect an Aurora MySQL database to an EC2 instance step-by-step. 🚀

<Disclaimer>
  **⚠️ Disclaimer:** Ensure your AWS account has sufficient permissions and budget limits before proceeding. AWS charges may apply for resources like RDS and EC2. Always clean up unused resources to avoid unexpected costs.
</Disclaimer>

***

## 🔑 Login with Your IAM User

### Step 1: Login to AWS

To get started, log in as your **IAM user**, not your root user.

1. Open the [AWS Console](https://aws.amazon.com/console/).

2. Log in using your **IAM Admin User** credentials.

3. If you don't have an IAM user, create one:

```plaintext theme={null}
IAM Setup Steps:
1. Open the IAM Console.
2. Navigate to "Users" and click "Create user."
3. Configure:
   - User name: YourName-IAM-Admin
   - Attach "AdministratorAccess" policy.
   - Set a strong password.
4. Save the `.csv` credentials file.
5. Log in using this user.
```

<Tip>
  💡 **Why IAM Users?**
  IAM users enable secure access to AWS services without exposing the root account.
</Tip>

***

## 🌍 Create an Aurora MySQL Database

### Step 2: Check Your AWS Region

1. Locate the region dropdown at the top-right corner of the AWS Console.

2. Ensure all resources (RDS, EC2, etc.) are created in the same region.

<Tip>
  💡 **Tip:** Choose the closest region to your location for lower latency.
</Tip>

### Step 3: Create Your Aurora Database

1. Open the **RDS Console** (search for "RDS" in the AWS search bar).

2. Click **Databases** > **Create Database**.

3. Configure your database:

   * **Engine type:** Aurora (MySQL-Compatible)

   * **Engine version:** Aurora MySQL 3.05.2 (compatible with MySQL 8.0.32).

   * **Template:** Development/Test

   * **DB Cluster Identifier:** `aurora-cluster`

   * **Master Username:** `admin`

   * **Master Password:** Strong password (e.g., `P@ssw0rd123`)

   * **Instance Class:** `db.t3.medium`

   * Enable **Storage Autoscaling** for flexibility.

   * Ensure the **VPC and Subnet Group** match your EC2 instance.

4. Leave other settings as default and click **Create Database**.

<Note>
  🚨 **Note:** Aurora's storage scales automatically, but charges may increase with usage. Monitor your RDS usage in the AWS Billing Console.
</Note>

***

## 🖥️ Launch an EC2 Instance

### Step 4: Create a Virtual Web Server

1. Open the **EC2 Console**.

2. Click **Launch Instance** and configure the following:

   * **Name:** `web-server`

   * **AMI:** Amazon Linux 2023 AMI (or any supported Linux OS).

   * **Instance Type:** `t2.micro` (Free Tier eligible).

   * **Key Pair:** Create a new key pair and download the `.pem` file for SSH access.

   * **Networking:**

     * Ensure the EC2 instance is launched in the same **VPC** as your Aurora database.

     * Attach a security group with:

       * **Inbound Rules:**

         * SSH (port 22): Allow your IP.

         * MySQL/Aurora (port 3306): Allow traffic from the EC2 instance.

         * HTTP/HTTPS (ports 80/443): Allow public traffic (optional).

3. Click **Launch Instance**.

<Tip>
  💡 **Tip:** Use the `chmod 400 keyfile.pem` command to secure your private key before SSH access.
</Tip>

***

## 🔗 Connect EC2 to Aurora Database

### Step 5: Test Connectivity

1. SSH into your EC2 instance:

```bash theme={null}
ssh -i "keyfile.pem" ec2-user@<EC2-Public-IP>
```

1. Install MySQL client:

```bash theme={null}
sudo yum install mysql -y
```

1. Test the connection to your Aurora database:

```bash theme={null}
mysql -h <Aurora-Endpoint> -u admin -p
```

Replace `<Aurora-Endpoint>` with your RDS endpoint from the AWS Console.

<Warning>
  🚨 **Common Issues:**

  * Ensure the Aurora security group allows traffic from the EC2 instance.

  * Verify that the endpoint and credentials are correct.
</Warning>

***

## 🚀 Next Steps

* Create a sample database and table in Aurora using the MySQL client:

```sql theme={null}
CREATE DATABASE sample_db;
USE sample_db;
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) UNIQUE NOT NULL
);
```

* Develop a web application that connects to your Aurora database.

* Deploy your web app and test database interactions.

***

### 🚩 Clean Up Resources

To avoid unnecessary costs, delete unused resources:

1. **Delete the RDS Cluster:** Go to the RDS Console, select your database, and choose **Delete**.

2. **Terminate the EC2 Instance:** Navigate to the EC2 Console, select the instance, and click **Terminate**.

<Warning>
  🚨 **Warning:** Ensure you have backups of any important data before deleting resources.
</Warning>

***

### 📚 Additional Resources

* [AWS Documentation](https://docs.aws.amazon.com/)

* [Aurora MySQL Overview](https://aws.amazon.com/rds/aurora/)

* [EC2 User Guide](https://docs.aws.amazon.com/ec2/)

* [RDS Pricing](https://aws.amazon.com/rds/pricing/)

Good luck and happy coding! 🎉

## 📧 Contact

For questions or feedback, reach out:

📨 Email: [projects@briankimemia.is-a.dev](mailto:projects@briankimemia.is-a.dev)
🌐 Portfolio: [Brian Kimemia](https://briankimemia.is-a.dev/)
**GitHub:** [BrianKN019](https://github.com/BrianKN019)

***

**Thank you for exploring this project! Let’s innovate and build secure AWS solutions together. 🚀**
