DEV Community

Cover image for EC2-and-S3-integration-for-Zappy-E-bank
Oluwatobi
Oluwatobi

Posted on

EC2-and-S3-integration-for-Zappy-E-bank

Mini Project: EC2-and-S3-integration-for-zappy-e-bank

Project Description:

Zappy E-bank plans to deploy its application on AWS ECS, with S3 buckets serving as the backbone for storage solutions, including customer data, transaction logs, and analytical data. The integration of EC2 and S3, facilitated by a reversed proxy setup, aims to provide a seamless experience for managing and accessing diverse resources under a unified access point.

Project Task:

EC2: Host the core application, enabling scalable computing capacity to meet growing customer demands.

S3: Offers secure, scalable objects strong for vast amounts of data, ensuring that Zappy E-bank can serve its customers efficiently and reliably.

Tips

A reverse Proxy will be configured on the EC2 instance, directing requests to the appropriate destination.

This also explains how to launch an EC2 instance

Step 1:

  • Login into the AWS console as an IAM user

1_aws

2_aws

Step 2:

Launching An Instance

  • Search for EC2

3_aws

  • Click on Launch Instance

4_aws

  • Insert your project Name

5_aws

  • Select an Operating system to run (I'll be using the Ubuntu instance)

5a_aws

  • Select Instance Type

6_aws

  • You can decide to generate a key pair if you want to connect to a local server, but I won't be needing it here

7_aws

  • Select Network Settings

9_aws

  • Proceed without key pair

10_aws

  • Connect to instance

12_aws

  • You have successfully created an instance

13_aws

Step 3:

Assigning a Static IP (Elastic IP)

Associating an Elastic IP address with your EC2 instance ensures it retains the same public IP address across reboots.

  • In the EC2 console navigation, select elastic IP and click on allocate elastic

14_aws

15_aws

  • Follow the highlighted part

6b_aws

  • Click on Associate

16_aws

17_aws

Step 4:

Creating S3 Bucket

  • Search S3 and click

20_aws

  • Create a new bucket and give it a name of your choice

21_aws

  • Create a new object inside the bucket. You should upload an index.html file containing

22_aws

23_aws

24_aws

25_aws

26_aws

  • On your computer, create an index.html file with the content "Welcome to Amazon

27_aws

28_aws

  • Upload the index.html on S3 bucket as shown in the image below;

29_aws

Step 5:

Configuring S3 Bucket for Web Hosting

  • Click on your bucket name

31_aws

  • Click on the properties tab and scroll down

32_aws

  • Click on edit

33_aws

34_aws

  • Copy the URL

35_aws

Step 6:

Configuring a web server as Reverse Proxy

  • On your EC2 instance, install Nginx web server

sudo apt update -y && sudo apt install nginx -y

36_aws

  • Configure the Web Server to Serve your S3 app directly and forward request to your S3 bucket

sudo vim /etc/nginx/sites-available/mybucket

37_aws

  • Paste the configuration code snippet below and replace the highlighted part with your S3 link
 server {
    listen 80;
    server_name 100.26.55.173;  # Replace with your domain name or server IP address

    location / {
        proxy_pass https://your-bucket-name.s3.amazonaws.com; # Replace with the link you generated after you enabled  static web hosting for your bucket
        proxy_set_header Host your-bucket-name.s3.amazonaws.com;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
Enter fullscreen mode Exit fullscreen mode

Note Make sure to replace the link above with the link you generated after you enabled static web hosting for your bucket

38_aws

Step 7:

Make your index.html public

  • Navigate to the index.html file, click on Action and then click on Make Public

39_aws

40_aws

Step 8:

Launch

  • insert this code to link the files
    sudo ln -s /etc/nginx/sites-available/mybucket /etc/nginx/sites-enabled

  • Then Restart the nginx
    sudo systemctl restart nginx

Snipaste_2024-07-29_20-46-27

  • Copy your Public URL and paste into your browser

Top comments (0)