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. πŸš€


πŸ”‘ 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.

  2. Log in using your IAM Admin User credentials.

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

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.

πŸ’‘ Why IAM Users? IAM users enable secure access to AWS services without exposing the root account.


🌍 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: Choose the closest region to your location for lower latency.

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: Aurora’s storage scales automatically, but charges may increase with usage. Monitor your RDS usage in the AWS Billing Console.


πŸ–₯️ 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: Use the chmod 400 keyfile.pem command to secure your private key before SSH access.


πŸ”— Connect EC2 to Aurora Database

Step 5: Test Connectivity

  1. SSH into your EC2 instance:
ssh -i "keyfile.pem" ec2-user@<EC2-Public-IP>
  1. Install MySQL client:
sudo yum install mysql -y
  1. Test the connection to your Aurora database:
mysql -h <Aurora-Endpoint> -u admin -p

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

🚨 Common Issues:

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

  • Verify that the endpoint and credentials are correct.


πŸš€ Next Steps

  • Create a sample database and table in Aurora using the MySQL client:
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: Ensure you have backups of any important data before deleting resources.


πŸ“š Additional Resources

Good luck and happy coding! πŸŽ‰

πŸ“§ Contact

For questions or feedback, reach out:

πŸ“¨ Email: projects@briankimemia.is-a.dev 🌐 Portfolio: Brian Kimemia GitHub: BrianKN019


Thank you for exploring this project! Let’s innovate and build secure AWS solutions together. πŸš€