In this post we going to use AWS S3 (Simple Storage Service) to host static content, this might also contain client-side scripts.

What is s3 ?

Amazon S3 has a simple web service interface that you can use to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites. The service aims to maximize benefits of scale and to pass those benefits on to developers

Requirements

  • AWS Account

Hands-On

  1. On AWS Management Console go to S3

2. On Buckets, click on Create Bucket

3. Give it a name, the name need to be unique in all the namespace of AWS, and you can leave the other configurations at default values

4. Click on Create bucket

5. once the bucket is created, click on the name, to access the properties

6. Click on the Properties tab

7. Go down the page, until you see the Static website hosting and click on Edit

8. On Static website hosting and select Enable, on index document write index.html, on Error document put error.html and Save changes.

9. Once you save the changes, copy the endpoint.

10. Go to the tab Permissions

11. On Block public access (bucket settings) click on Edit

12. Uncheck all the chebox and Save changes

13. Confirm

14. Go back to Buckets, click on the bucket name

15. Go to Objects and click on Upload

16. Create the html files, use a text editor and save it as html, I alredy have two files on my computer, called index.html and error.html, the content of index.html is "Hello, world from s3" and the error.html is "This is the error page from s3"

17. In the upload page, click on Add files and add the index.html and error.html

18. Click on Upload at the end of the page.

19. You will get the Upload status

20. Click on exit, and now in the objects, select the files and click on Actions, and click on Make public

21. Confirm

22. You will see the make public status

23. Open the s3 endpoint in your browser and you will see the index page

24. if you try to access a sub page doest not exist for example http://(s3 endpoint)/testing you will see the error page

Great! you have a static website on the AWS S3, in the next post we going deeper into the AWS Services.

Clean-UP

  1. In S3, Buckets, select the bucket and go to Objects.

2. On Objects, select all the files and click on Delete

3. Confirm

4. On S3 Buckets, select the bucket and click on Delete

5. Confirm