EXPERIMENT-1
STATEMENTS: Designing a static website hosting using Amazon s3
DESCRIPTION:
AWS S3 stands for Amazon Simple Storage Service. It is a cloud-based storage service that can
scale to an enormous size and provide high performance, availability, reliability, and security. It
is a very cost-effective and secure replacement for your on-premises data center. The data is
stored on cloud servers can be accessed through other web applications and websites globally.
Apart from data storage functionality, the AWS S3 bucket provides a remarkable feature of static
website hosting over it.
Amazon S3 Concepts
1. Buckets
2. Objects
3. Keys
4. Regions
Buckets
1. A bucket is a container used for storing the objects.
2. Every object is incorporated in a bucket.
3. For example, if the object named photos/milky.jpg is stored in the milky bucket
4. it can be addressed by using the URL http://milky.s3.amazonaws.com/photos/milky.jpg.
5. A bucket has no limit to the amount of objects that it can store.
6. The AWS user that creates a bucket owns it.
7. The AWS account that creates a bucket can delete a bucket, but no other AWS user can
delete the bucket.
Objects
1. Objects are the entities which are stored in an S3 bucket.
2. An object consists of object data and metadata where metadata is a set of name-value
pair that describes the data.
3. It is uniquely identified within a bucket by key and version ID.
Key
1. A key is a unique identifier for an object.
2. Every object in a bucket is associated with one key.
Regions
1. You can choose a geographical region in which you want to store the buckets that you
have created.
PROCEDURE:
Step 1: Create a bucket
Step 2: Enable static website hosting
Step 3: Edit Block Public Access settings
Step 4: Add a bucket policy that makes your bucket content publicly available
Step 5: Configure an index document
Step 6: Configure an error document
Step 7: Test your website endpoint
Step 8: Clean up
Create an S3 bucket on AWS
The first step to hosting a static website on AWS S3 is to create an S3 bucket in your account.
After creating the bucket, we will upload the website contents and files in our bucket. The
website content will then be assigned specific permissions to be accessible to the public.
Click on the Create bucket button to configure and create a new bucket
Next, you need to provide your S3 bucket name, the region where you want your bucket to be
created, and then configure your bucket’s security and privacy setting
Now, you have finished setting up your bucket, leave other options and settings as it is, and just
click on the Create Bucket button at the bottom right corner
STEP2: Enable static website Hosting
1. Choose Properties.
2. Under Static website hosting, choose Edit.
3. Choose Use this bucket to host a website.
4. Under Static website hosting, choose Enable.
5. In Index document, enter the file name of the index document, typically index.html.
6. To provide your own custom error document like error.html (optional)
7. Choose Save changes
8. Under Static website hosting, note the Endpoint.
STEP3: Edit Block Public Access settings
1. Choose the name of the bucket
2. Choose Permissions.
3. Under Block public access (bucket settings), choose Edit.
4. Clear Block all public access, and choose Save changes.
Step 4: Add a bucket policy that makes your bucket content publicly available
1. Under Buckets, choose the name of your bucket.
2. Choose Permissions.
3. Under Bucket Policy, choose Edit.
4. To grant public read access for your website
5. Choose Save changes
Step 5: Configure an index document
1. Create an index.html file.
<Html>
<head>
<title>
Registration Page
</title>
</head>
<body bgcolor="pink">
<center> ANNAMACHARYA INSTITUTE OF TECHNOLOGY AND SCIENCES RAJAMPET
</center>
<center> (AUTONOMOUS)</center>
<br>
<br>
<form>
<label> Firstname </label>
<input type="text" name="firstname" size="15"/> <br> <br>
<label> Middlename: </label>
<input type="text" name="middlename" size="15"/> <br> <br>
<label> Lastname: </label>
<input type="text" name="lastname" size="15"/> <br> <br>
<label>
Course :
</label>
<select>
<option value="Course">Course</option>
<option value="BCA">BCA</option>
<option value="BBA">BBA</option>
<option value="B.Tech">B.Tech</option>
<option value="MBA">MBA</option>
<option value="MCA">MCA</option>
<option value="M.Tech">M.Tech</option>
</select>
<br>
<br>
<label>
Gender :
</label><br>
<input type="radio" name="male"/> Male <br>
<input type="radio" name="female"/> Female <br>
<input type="radio" name="other"/> Other
<br>
<br>
<label>
Phone :
</label>
<input type="text" name="country code" value="+91" size="2"/>
<input type="text" name="phone" size="10"/> <br> <br>
Address
<br>
<textarea cols="80" rows="5" value="address">
</textarea>
<br> <br>
Email:
<input type="email" id="email" name="email"/> <br>
<br> <br>
Password:
<input type="Password" id="pass" name="pass"> <br>
<br> <br>
Re-type password:
<input type="Password" id="repass" name="repass"> <br> <br>
<input type="button" value="Submit"/>
</form>
</body>
</html>
2. Save the index file locally.
Step 6: Configure an error document
1. Create an error document, for example 404.html
<html>
<head>
<title>My Website Home Page</title>
</head>
<body>
<h1>OOPS!</h1>
<b><p>Sorry.....please try again</b></p>
</body>
</html>
2. Save the error file locally.
To upload the index document to your bucket, do one of the following:
1. Drag and drop the index file into the console bucket listing.
2. Choose Upload, and follow the prompts to choose and upload the index file.
3. Choose Upload, and follow the prompts to choose and upload the error file.
Step 7: Test your website endpoint
After you configure static website hosting for your bucket, you can test your website endpoint.
1. Under Buckets, choose the name of your bucket.
2. Choose Properties.
3. At the bottom of the page, under Static website hosting, choose your Bucket website
endpoint.
SAMPLE OUTPUT: