Randy Ideas

"Deploying Your Website on AWS: A Step-by-Step Guide"

Deploying a website on AWS (Amazon Web Services) can help you to scale your online presence and leverage powerful services like Amazon S3 for storage and Elastic Beanstalk for application deployment. This guide will walk you through the process, making it easy to understand and implement.

AWS Tutorial :How host a static website using AWS amplify | AWS Amplify
AWS Tutorial :How host a static website using AWS amplify | AWS Amplify

Before diving into the main topics, let's ensure you have an AWS account. If you don't have one, you can create it at aws.amazon.com. Now, let's proceed with deploying your website.

Steps to deploy the website on AWS
Steps to deploy the website on AWS

Creating an S3 Bucket for Website Hosting

The first step is to create an S3 bucket to store your website files. Amazon S3 is a highly scalable and secure storage service.

How to Host WordPress on Amazon Hosting EC2
How to Host WordPress on Amazon Hosting EC2

Once you log into your AWS Management Console, search for 'S3' and select it. Click 'Create bucket' and follow these steps:

Bucket Configuration

AWS EC2 Explained ☁️ Amazon Elastic Compute Cloud Cheat Sheet for Beginners
AWS EC2 Explained ☁️ Amazon Elastic Compute Cloud Cheat Sheet for Beginners

Bucket name: Choose a unique name for your bucket. For a website, this will be your domain name (e.g., 'yourdomain.com').

Bucket region: Choose the geographic region where you want your bucket to reside.

Bucket Access Rights

Under 'Block all public access', click 'Unblock current settings' and then 'Save'. This allows you to modify the permissions later.

Now, navigate to the newly created bucket, go to the 'Properties' tab, and scroll down to 'Static website hosting'. Here's how to set it up:

  • Select 'Enabled',
  • Enter 'index.html' as the 'Index document',
  • Leave 'Error document' blank,
  • Click 'Save changes',
  • Grant 'Everyone' group 'Read' permission to your bucket,
  • Make your files public by adding a 'Public' permission to them.

Uploading Your Website Files

Now that your S3 bucket is configured, you can upload your website files. The goal is to host a simple static website with an index.html file at the root.

After uploading, double-check that all files are publicly accessible and your 'index.html' file is at the root level.

Confirming Your Domain Name

Buy a domain name if you haven't already, then point your domain to your S3 bucket using a CloudFront distribution, making the process more efficient and secure.

Alternatively, use the S3 bucket name as your domain. e.g., 'yourdomain.com.s3-website.us-east-1.amazonaws.com'

Setting Up a Custom Domain with CloudFront

Create an alias in CloudFront to use your custom domain name. This process involves creating a CloudFront distribution and adding an alternate domain name.

Monitoring Your Website with CloudWatch

To ensure your website is running smoothly, set up basic monitoring using CloudWatch.

In the AWS Management Console, search for 'CloudWatch' and select it. Navigate to 'Metrics', then 'S3'. Here's how to create an alarm:

Creating an Alarm

Choose metrics based on your website's requirements (e.g., 'Get / List All Objects' for total objects).

Set the 'Statistic' to 'Sum' and the 'Period' to a suitable value (e.g., '1 minute').

Configuring the Alarm

Set the 'Statistic' to 'Sum' and the 'Period' to a suitable value (e.g., '1 minute').

Define the conditions under which an alarm is triggered. For example, set a lower threshold (e.g., '1') if you expect high traffic and want to be notified if it drops.

That's it! You've successfully deployed your website on AWS. Now, check your Domain NameSettings that everything is working correctly, and you should see your website online. Keep monitoring with CloudWatch and make adjustments as needed.

Read Next