Fun Projects to Leverage AWS

Ritu Srivastava
4 min readJun 2, 2024

--

Part -1

Hey Everybody! I hope you all are doing fantastic.

Introduction

Embarking on the journey to learn Amazon Web Services (AWS) is an exciting and rewarding endeavor, offering numerous possibilities for those eager to enhance their cloud computing skills. To make the learning experience more engaging, I have curated 5 fun projects, to showcase the versatility of AWS and gain hands-on experience in deploying real-world solutions. Let’s start with project -1 and then 2,3,4, and so on to the next blogs. For that, you can visit to this YouTube channel:

https://www.youtube.com/@ITCorporate_Couple

Project # 1 — Launch a static website on Amazon S3

Discover an affordable and efficient way to host your website by deploying a static site on Amazon S3 — an ideal introduction to key AWS services. Create an S3 bucket to leverage simplicity and scalability, and enhance global accessibility using Amazon CloudFront as your CDN. Seamlessly manage your domain with Amazon Route 53, and implement SSL/TLS security through AWS Certificate Manager for a secure HTTPS connection, ensuring optimal performance and security for your website.

Before deploying, make sure your static website files (HTML, CSS, JavaScript, images, etc.) are ready in a local directory.

Create an S3 Bucket

  1. Go to the AWS Management Console.
  2. Navigate to S3 and click on “Create bucket.”
  3. Enter a unique bucket name, select a region, and click “Next.”
  4. On the “Configure options” page, click “Next.”
  5. You can configure bucket policies on the “Set permissions” page if needed. Click “Next” to review, then click “Create bucket.”

OR

aws s3api create-bucket --bucket YOUR_UNIQUE_BUCKET_NAME --region YOUR_REGION

Upload Your Website to the S3 Bucket

  1. Open your newly created S3 bucket.
  2. Click on the “Upload” button and select all your website files.
  3. Ensure that the files are set to be publicly accessible. You can do this by selecting each file, clicking on “Actions,” and choosing “Make public.”

OR

aws s3 sync YOUR_LOCAL_WEBSITE_DIRECTORY s3://YOUR_UNIQUE_BUCKET_NAME --acl public-read

Enable Static Website Hosting on the S3 Bucke

  1. In the S3 bucket, go to the “Properties” tab.
  2. Click on “Static website hosting.”
  3. Select “Use this bucket to host a website.”
  4. Set the “Index document” to your main HTML file (e.g., index.html) and optionally set the "Error document."
  5. Save the changes.

OR

aws s3 website s3://YOUR_UNIQUE_BUCKET_NAME --index-document index.html

Configure Amazon CloudFront Distribution

  1. Go to the CloudFront console.
  2. Click “Create Distribution.”
  3. Choose “Web” distribution.
  4. Set the following configurations:
  • Origin Domain Name: Select your S3 bucket from the dropdown.
  • Default Root Object: Set it to your main HTML file (e.g., index.html).
  • Leave other settings as default or adjust based on your requirements.

5. Click “Create Distribution.”

OR

import boto3
cloudfront_client = boto3.client('cloudfront')distribution_config = {
'CallerReference': 'your-unique-caller-reference',
'Origins': {
'Quantity': 1,
'Items': [
{
'Id': 'S3-origin',
'DomainName': 'YOUR_UNIQUE_BUCKET_NAME.s3.amazonaws.com',
'S3OriginConfig': {
'OriginAccessIdentity': ''
}
}
]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'S3-origin',
'ForwardedValues': {
'QueryString': False,
'Cookies': {'Forward': 'none'},
'Headers': {'Quantity': 0}
},
'TrustedSigners': {'Enabled': False, 'Quantity': 0},
'ViewerProtocolPolicy': 'allow-all',
'MinTTL': 0
},
'Comment': 'Your CloudFront Distribution Comment',
'Enabled': True
}
response = cloudfront_client.create_distribution(DistributionConfig=distribution_config)
distribution_id = response['Distribution']['Id']
print(f"CloudFront Distribution ID: {distribution_id}")

Update Amazon Route 53 for Your Domain

  1. Go to the Route 53 console.
  2. Create a new hosted zone for your domain if you haven’t already.
  3. Note the four nameservers provided for your hosted zone.
  4. In your domain registrar’s settings, update the nameservers to the ones provided by Route 53.

Obtain an SSL/TLS Certificate using AWS Certificate Manager (ACM)

  1. Go to the ACM console.
  2. Click “Request a certificate.”
  3. Enter your domain name and follow the instructions to validate ownership.
  4. Once validated, select the option to create a new CloudFront distribution.
  5. Choose the CloudFront distribution you created earlier and complete the certificate request.

OR

import boto3
acm_client = boto3.client('acm')certificate_arn = acm_client.request_certificate(
DomainName='yourdomain.com',
ValidationMethod='DNS'
)['CertificateArn']
print(f"Certificate ARN: {certificate_arn}")

Update CloudFront Distribution to Use SSL/TLS

  1. Go to the CloudFront console.
  2. Select your distribution and click “Edit.”
  3. Under the “General” tab, change the “Viewer Protocol Policy” to “Redirect HTTP to HTTPS.”
  4. Save the changes.

OR

cloudfront_client = boto3.client('cloudfront')
cloudfront_client.update_distribution(
DistributionConfig={
'DistributionConfig': {
'DefaultCacheBehavior': {
'ViewerProtocolPolicy': 'redirect-to-https'
}
},
'Id': 'YOUR_CLOUDFRONT_DISTRIBUTION_ID',
'IfMatch': 'your-distribution-config-if-match'
}
)

Wait for Changes to Propagate

It may take some time for changes to propagate. Once complete, your static website should be accessible via the custom domain over HTTPS globally through CloudFront.

Congratulations! You’ve successfully deployed a static website on Amazon S3, configured CloudFront for global content delivery, and set up DNS with Route 53 and SSL/TLS with ACM.

#follow for more such projects to learn AAWS. All the best!

--

--

Ritu Srivastava
Ritu Srivastava

Written by Ritu Srivastava

Outspoken Lady! Tech, Trek and Travel. Laughing out loud mess-ter-peace ;)