Day 89: Mastering AWS- Mounting an S3 Bucket on Amazon EC2 Linux with S3FS

Day 89: Mastering AWS- Mounting an S3 Bucket on Amazon EC2 Linux with S3FS

Project Overview: Embark on an enriching journey into Amazon Web Services (AWS) with this project, meticulously crafted to guide you through mounting an AWS S3 bucket on an Amazon EC2 Linux instance using S3FS. Gain invaluable experience with AWS services such as S3, EC2, IAM, and learn to seamlessly integrate cloud storage into your Linux-based infrastructure.

Task: Mounting an S3 Bucket on Amazon EC2 Linux Using S3FS

Step-by-Step Guide:

Step 1: IAM User Setup

  1. Log in to your AWS Management Console.

  2. Navigate to the IAM (Identity and Access Management) service.

  3. Click on "Users" in the left-hand menu and then "Add user."

  4. Enter a username and set permissions for S3 access.

  5. Review and create the user, ensuring to save the access key and secret access key for later use.

Step 2: Install and Configure aws-cli

  1. Log in to your EC2 Linux instance.

  2. Install the AWS Command Line Interface (aws-cli) if not already installed using package manager like apt.

       sudo apt update
       sudo apt install awscli -y
    

  3. Configure aws-cli with the IAM user's access keys, default region, and preferred output format by running aws configure.

       aws configure
    

    Enter your access key, secret key, default region, and preferred output format.

Step 3: Test AWS Configuration

  1. Confirm that aws-cli is correctly configured by running aws s3 ls. This command should list your S3 buckets.

       aws s3 ls
    

  2. Create a new S3 bucket from the AWS Management Console to use in the project.

Step 4: Mount the S3 Bucket Using S3FS

  1. Install S3FS on your EC2 instance using package manager like apt.

       sudo apt-get update
       sudo apt-get install s3fs -y
    
  2. Create a directory for mounting the S3 bucket, e.g., mkdir /home/ubuntu/bucket.

       mkdir /home/ubuntu/bucket
    

  3. Add some 2–3 files in /home/ubuntu/bucket.

       :~/bucket$ touch Vedant.txt Ved-10.txt Tom.txt
    

  4. Synchronize files between the local directory and the S3 bucket using aws s3 sync ~/bucket <your-bucket-name>.

       aws s3 sync ~/bucket <your-bucket-name> 
       aws s3 sync /home/ubuntu/bucket s3://proj-10-bucket
    

Step 5: Access S3 Data

  1. Navigate to the designated directory on your EC2 instance where the S3 bucket is mounted, e.g., /home/ubuntu/bucket.

  2. Interact with the S3 bucket's contents as if they were local files, facilitating seamless data management.

Project Conclusion: By meticulously following each step outlined in this project, you've acquired a profound understanding of setting up AWS resources, configuring aws-cli, installing S3FS, and mounting an AWS S3 bucket on an Amazon EC2 Linux instance. Armed with this knowledge, you're well-equipped to seamlessly integrate cloud storage within Linux environments using AWS services.

Continue your exploration of AWS by delving into automation, access control mechanisms, and application integration possibilities with S3 bucket data. As you navigate the expansive AWS ecosystem, your expertise in cloud computing and infrastructure management will flourish, paving the way for innovative solutions and transformative experiences.

Stay curious, keep exploring, and let your AWS journey unfold with boundless possibilities!