USE CASE
As a newly employed cloud engineer, I have been asked to create a multi-tier architecture. This architecture should consist of a website where HTML files can be stored and have an API to handle client requests. Additionally, I want to ensure that when we build our website, every user globally has the same experience, with minimal delay.
Introduction
Welcome to our comprehensive guide on building a scalable and secure multi-tier architecture using Amazon S3, EC2, and RDS. In this article, I will walk you through each step, explaining the process in detail.
Prerequisites
Before we begin, let's review the prerequisites:
- Simple Storage Service (S3): Stores static assets (HTML, CSS, JavaScript, images, videos) and hosts your static website.
- Elastic Compute Cloud (EC2): Runs web server software, handles HTTP requests, and processes dynamic content.
- Relational Database Service (RDS): Stores sensitive and structured data as a backup.
- CloudFront: A content delivery network (CDN) that distributes website content globally, reducing latency and improving performance.
Let's Dive into EC2
As we all know, EC2 is a web server. In our multi-tier architecture, this EC2 instance will serve as an API that collects client requests. Ec2 helps you to secure and scalable server to host your web Application
Step 1: Launch an EC2 Instance
Step 2: Choose Amazon Machine Image (AMI)
Step 3: Select Instance Type
Choose the right instance type for your workload.
Step 4: Create a Key Pair
Generate a secure key pair for SSH access.
A key pair is important because;
- Ensures secure SSH access.
- Protects your instance from unauthorized access.
Step 5: Click on Launch instance.
INTRODUCTION TO AMAZON RDS
Amazon Relational Database Service supports automatic failover and automated backups. This ensures you can handle data loss or downtime because of hardware failure. The database provides high availability and scalability for your application. We want our website to be available at every time and that is why we are introducing RDS. Let's create RDS, this will be connected to EC2.
Now that we have created our RDS, let install some packages.
Now let's create S3 Bucket for storage.
Step 2:Give our bucket a name and unchecked the public asset. We want our website to be accessible publicly.
We will leave everything at default and create our bucket.
Let's go ahead and click on the bucket we just created, what next is to upload our HTML file to S3.
Next thing is to configure S3 Bucket Policy: Define permissions for bucket access.
Let's enable static website and copy the URL and viola our website is life but we are not done yet.
We are going to copied the URL for our website and paste to a browser.
Let's Create IAM Role for EC2-S3 Connection : This is to establish secure communication between EC2 and S3.As earlier said, the EC2 will serve as API that collects client request.
Let's create IAM role that we be attached to EC2.
The role has been created, let go ahead and click on the role created and attached permission to it.
We want this role to have access to our S3, so we select S3 for "service"
Note: Kindly put the bucket ARN to all the permission under resource.
Now that we have created our role, let's assign the IAM role to EC2 instance that was created.
Let's connect to the EC2 instance and run some commands.
Introduce CloudFront:
Now let's dive in.
Like we said earlier, we want our users globally to be able to access our website within a minimum TTL. The website will be cached so that users can access it within a minimized time.
Let's copied our static website URL and copied it to the origin domain.
Let's Copy the distribution and paste it to a browser, it's going to direct us to our website.
Congratulations! You have successfully created a multi-tier architecture using S3, EC2, and RDS. This scalable and secure architecture will host your web application, store static assets, and distribute content globally.
Top comments (0)