Create a free website to share large files stored on AWS S3
Tags: aws, s3, filesharing, easy
Published: 2023-11-01 14:48:04


## Create a free website to share large files stored on AWS S3

### AWS Cloud Hands on Lab Practice Series

![](https://cdn-images-1.medium.com/max/3168/1*MWy_KcJ9QS54Qs2shHgGiA.png)

>  **Project Overview —**

This project revolves around AWS S3 where we configure an temporary storage or file sharing website to share resources quickly. By leveraging AWS S3 static website hosting we configure our bucket as a static website, the website is available at the AWS Region-specific website endpoint of the bucket.

>  **SOLUTIONS ARCHITECTURE OVERVIEW -**

![](https://cdn-images-1.medium.com/max/2000/1*uSQ02RUm0hwhVxiVWU37gA.png)

>  **First Let’s understand the real world use case :**

* **File Sharing and Distribution —** You can use presigned URLs to allow users to download large files, such as video files, software installers, datasets, etc., directly from your S3 bucket. This can be especially useful for distributing content to a large audience without overwhelming your server infrastructure.

* **Secure File Sharing:** Presigned URLs have an expiration time, making them ideal for secure file sharing. For instance, you can generate a presigned URL for a file that expires after a certain period, thus controlling access to the file. Also share private content securely, restricting access only to intended recipients by providing time-limited links.

* **Temporary Access to Files:** When your application needs temporary access to specific files in S3 (e.g., for generating dynamic content), presigned URLs can be used for access without compromising security.

* **Media Distribution:** For media or streaming applications, you can create presigned URLs to enable temporary access to specific video or audio content. This allows users to access content for a limited time without directly exposing the S3 bucket.

* **Backup and Restore Operations:** Generate presigned URLs for specific backup files or data. This can aid in sharing and restoring backups securely, restricting access after a set time frame.

* In essence, using S3 with presigned URLs for sharing content allows for flexible, secure, and controlled access to specific files or objects in an S3 bucket. This method is ideal for scenarios where quick and easy transfer of files or objects is necessary.

* **This is not for production grade solution. It compromises security risk of making s3 bucket & objects public.**

>  **Prerequisite —**

* AWS Account with Admin privileges

* Access to AWS S3 & IAM

>  **AWS Services Usage —**

* AWS S3

* AWS IAM

>  **STEP BY STEP GUIDE -**

**STEP 1 : Creating AWS S3 bucket through console.**

* Login to AWS account, Navigate to AWS S3 Service.

* Click on create bucket

* Provide Unique Bucket Name (It will be website name)

* Select the AWS Region according to nearest user location.

* Uncheck the Block all public access.

* Tick Mark — I acknowledge that the current settings might result in this bucket and the objects within becoming public.

* Keep rest of the settings as is & hit Create bucket.

![](https://cdn-images-1.medium.com/max/3488/1*7IIxBueKfeodfht7PNXg1A.png)

![](https://cdn-images-1.medium.com/max/2244/1*ESqEIMGf-VHV2rGvglO7fA.png)

![](https://cdn-images-1.medium.com/max/2000/1*V8-kQAwFGoIjbrKOTjaI0Q.png)

![](https://cdn-images-1.medium.com/max/2000/1*SLfKzQSGxWqSQkCGxuChtQ.png)

>  PRO TIP: Alternatively you can create through AWS CLI if cli is configured
>  **aws s3 mb s3://bucket_name — region region-code**

**STEP 2 : Creating AWS S3 bucket policy through console.**

* Navigate to permissions tab of newly created s3 bucket.

* Copy, edit & paste it in the policy section
>  {
 “Version”: “2012–10–17”,
 “Statement”: [
 {
 “Effect”: “Allow”,
 “Principal”: “*”,
 “Action”: “s3:GetObject”,
 “Resource”: “<s3-bucket-arn>/*”
 }
 ]
}

![](https://cdn-images-1.medium.com/max/2616/1*gqV096vRuguoCk5Ruo8jOg.png)

* Edit the bucket ARN & validate the json formatting & save it.

* This policy allow anyone to make GET request from Internet.

**STEP 3 : Enable Static website hosting**

* Navigate to properties tab on your bucket.

* Scroll till down to enable static website hosting.

* select Host a static website

* index document → index.html -> save

* You will get a FQDN which is accessible over internet to serve the content.

![](https://cdn-images-1.medium.com/max/2000/1*-mTmwkrY85j9TJDcMurnVw.png)

![](https://cdn-images-1.medium.com/max/2000/1*7hqKvuQ9hgyb-HleYONWvA.png)

![](https://cdn-images-1.medium.com/max/2630/1*OxgmJKASM4pewLBSHrqFYg.png)

**STEP 4: Upload contents on s3 & create presigned URLs**

* Now upload files on your s3 bucket through console.

* After successful uploads

* Go to specific object -> Actions -> Share with a presigned URL

* Give the timeline according to how long you want the presigned URL to be active ( maximum is 12 hours )

* Copy the URL & save it for future use.

![](https://cdn-images-1.medium.com/max/2000/1*F0PqlfhEaphCa9G7wOadvA.png)

![](https://cdn-images-1.medium.com/max/2630/1*38tC136Jo9I3JspVqtddFA.png)

![](https://cdn-images-1.medium.com/max/2000/1*LicWvs5nzqIg7qrUDamQ2g.png)

**STEP 5: Create index.html & upload it.**

* Create a file named index.html in notepad & edit it with below content.

* format it & validate the html syntax.

* You can update the content of index.html as per your choice.

* Upload the index.html on s3 bucket.

* Your website is up & ready to be shared !! Congrats…

```
>  <!DOCTYPE html>
<html>
<head>
 <title>Download Links</title>
</head>
<body>
 <h1>Download Links — Below links will get expired in next 8 hours</h1>
 <h2>Click on each file names to download & create folders according to its Title</h1>
 <ul>
DOWNLOAD LINKS
 <li><a href=”PRESIGNED URL THAT YOU COPIED & SAVED IN ABOVE STEP”>FILE NAME</a></li>
 <! — Add more links as needed →
 </ul>
</body>
</html>
```

![](https://cdn-images-1.medium.com/max/2550/1*EWPvIkpdwDtHXgtIxfbaoA.png)

**STEP 6: Decommission**

* Delete s3 buckets & its content.

**NOTE —** **This is not for production grade solution. It compromises security risk of making s3 bucket & objects public.**

## Congrats ! We have successfully completed lab for creating a website acting like temporary Google Drive on AWS S3.

![](https://cdn-images-1.medium.com/max/3144/1*BxfgHQkXG7JLHn9ohjYVeg.png)

*I am Kunal Shah, AWS Certified Solutions Architect, helping clients to achieve optimal solutions on the Cloud. Cloud Enabler by choice, DevOps Practitioner having 8+ Years of overall experience in the IT industry.*

*I love to talk about Cloud Technology, DevOps, Digital Transformation, Analytics, Infrastructure, Dev Tools, Operational efficiency, Serverless, Cost Optimization, Cloud Networking & Security.*

#aws #community #builders #devops #s3 #google #drive #storage #solution #management #centralize #quick #easy #large #file #sharing #operations #infrastructure #scalable #reliable #controlled #design #acloudguy

*You can reach out to me @ [acloudguy.in](https://acloudguy.in/)*