03_RV_4th_sem_static_website_s3_cfnt (1)
03_RV_4th_sem_static_website_s3_cfnt (1)
Requirements
An AWS account.
Basic knowledge of AWS services.
A simple static website (HTML/CSS/JS files). You can create a basic HTML page if
you don’t have one.
Architecture Diagram
Tasks
Task 1: Create an S3 Bucket for Static Website Hosting
Amazon S3 (Simple Storage Service) provides object storage that can be used for hosting
static websites.
1. Log in to the AWS Management Console.
• Region: Select the region closest to your target audience. (E.g., Mumbai (ap-
south-1). Make sure in the Object Ownership, ACLs disabled option is selected.
• Block Public Access Settings: Uncheck the box labeled Block all public access. A
static website needs to be publicly accessible.
• In the warning prompt that appears, confirm the changes by checking the
acknowledgment box.
• Leave other options as default and click on Create bucket to complete the creation.
Note: Set the S3 Bucket name in this format < AWS Username >-< keywords >. For
example, if your AWS username is user-10, the name of the bucket can be “user-10-
statics3lab”
4. Upload Your Website Files:
• Download the Source HTML and other static files from the following link
https://rvcollege-srcfiles.s3.ap-south-1.amazonaws.com/staticwebsite-srcfiles.zip
• Extract it in your local computer. These files have to be uploaded in the bucket you
just created.
• Click on your newly created bucket to open it.
• Click Upload.
• Click Add files and select all your HTML and other static image files for your static
website as shown below.
• After adding the files, click Upload at the bottom of the page to complete the
process.
• Rename the HTML file as index.html. Select the Object, click on Actions >
Rename Object.
• Select Enable.
• Index Document: Type index.html (or the name of your home page).
• (Optional) If there ia a custom error page (e.g., 404.html), enter it in the Error
Document field.
"Version": "2012-10-17",
"Statement": [
{
"Sid": "granting-access-to-s3-objects",
"Principal": "*",
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": "arn:aws:s3:::<YOUR-BUCKET-NAME-HERE>/*"
}
]
}
• Click the Save changes.
• After creating a new OAC, CloudFront will prompt you to update the S3 bucket policy
to ensure S3 access is restricted to CloudFront.
• Under Default cache behavior, leave everything as default. Make sure the cache
policy is set to CachingOptimized
• Under Web Application Firewall (WAF), select Do not enable security protections to
keep this demo simple. However, in production scenarios, this will change.
• Under Settings, choose Use North America, Europe, Asia, Middle East, and Africa
to keep costs lower, or choose Use all edge locations for global distribution. Also,
set index.html as the Default root object as shown below.
• (Optional) Alternate Domain Names (CNAMEs): If you plan to use a custom domain
(e.g., www.mywebsite.com), enter it here. Otherwise, leave it blank.
• (Optional) SSL Certificate: If you’re using a custom domain, select Custom SSL
Certificate and choose one from AWS Certificate Manager (ACM). If not, select
Default CloudFront Certificate (which uses CloudFront's domain).
• Review all settings and click Create Distribution.
• It may take several minutes for CloudFront to create and deploy your distribution.
• Open this URL in your browser to test whether your website is now served through
CloudFront.