Skip to content

GiraldoYeison/AWShostingStaticSite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

AWShostingStaticSite

Hosting a Static Website

Hosting a Static Website in AWS

Creation Date: November 27, 2023
Created By: Yeison Giraldo

💻 Static websites have unchanging content and lack backend processing capabilities

They comprise HTML pages, images, style sheets, and all necessary files for website rendering. Unlike dynamic websites, static ones don't employ server-side scripting or a database. To introduce interactivity and execute programming logic on static webpages, JavaScript can be utilized, running directly in the user's web browser.

Hosting a static website on Amazon Simple Storage Service (Amazon S3) is a straightforward process. You can achieve this by uploading the content and configuring it for public access. The beauty of this approach lies in the absence of the need for servers. Amazon S3 provides a versatile solution for storing and retrieving any volume of data at any given time, accessible from anywhere on the web.

Upon completing the lab, you'll gain the ability to:

  1. Create a bucket in Amazon S3

  2. Upload content to your bucket

  3. Enable access to the objects within the bucket

  4. Update the website

1. In the AWS Management Console, on the Services menu, choose S3.

In the AWS Management Console, on the Services menu, choose S3.

2. Choose Create bucket

Choose Create bucket

3. Type "website-123"

An S3 bucket name must be globally unique, and the naming space is shared among all AWS accounts. Once a bucket is created, its name becomes unavailable for use by any other AWS account in any AWS Region unless the bucket is deleted.

Therefore, for the purposes of this lab, it is recommended to employ a unique bucket name that incorporates a random number, for instance: "website-123."

Type "website-123"

4. Select ACLs enabled

In the Object Ownership section, select ACLs enabled, then verify Bucket owner preferred is selected.

Select ACLs enabled

5. Uncheck Block all public access

Clear Block all public access, then select the box that states I acknowledge that the current settings may result in this bucket and the objects within becoming public.

Uncheck Block all public access

6. Check I acknowledge that the current settings might result in this bucket and the objects within becoming public.

Check I acknowledge that the current settings might result in this bucket and the objects within becoming public.

7. Click on Create bucket

Click on Create bucket

8. Click on website-3051

Click on website-3051

9. Click on Properties

Click on Properties

10. Scroll to the Tags panel.

Choose Edit then Add tag and enter:

Scroll to the Tags panel.

11. Click on Add tag

Click on Add tag

12. Choose Edit then Add tag and enter:

  • Key: Department

  • Value: Marketing

Choose Edit then Add tag and enter:

13. Stay in the Properties console.

Scroll to the Static website hosting panel.

Stay in the Properties console.

14. Configure the following settings:

  • Static web hosting: Enable

  • Hosting type: Host a static website

  • Index document: index.html

    • Note: You must enter this value, even though it is already displayed.

  • Error document: error.html

    Choose Save changes

Configure the following settings:

15. In the Static website hosting panel, choose the link under Bucket website endpoint.

In the Static website hosting panel, choose the link under Bucket website endpoint.

16. Click on 403 Forbidden…

You will receive a 403 Forbidden message because the bucket permissions have not been configured yet. Keep this tab open in your web browser so that you can return to it later.

Your bucket has now been configured to host a static website.

Click on 403 Forbidden…

# Task 2: Uploading content to your bucket

In this task, you will upload the files that will serve as your static website to the bucket.

17. Return to the Amazon S3 console and in the website-<123> bucket you created earlier, choose the Objects tab

Return to the Amazon S3 console and in the website-<123> bucket you created earlier, choose the Objects tab

18. Click on Upload

Click on Upload

19. Click on Add files

Locate and select the three files that you downloaded.

Click on Add files

20. Click on Upload

Click on Upload

21. Click on Close

Click on Close

# Task 3: Enabling access to the objects

Objects that are stored in Amazon S3 are private by default. This ensures that your organization's data remains secure.

In this task, you will make the uploaded objects publicly accessible.

# You can make Amazon S3 objects public through two different ways:

  • To make either a whole bucket public, or a specific directory in a bucket public, use a bucket policy.

  • To make individual objects in a bucket public, use an access control list (ACL).

It is normally safer to make individual objects public because this avoids accidentally making other objects public. However, if you know that the entire bucket contains no sensitive information, you can use a bucket policy.

You will now configure the individual objects to be publicly accessible.

22. Select all three objects.

Select all three objects.

23. Click on Make public using ACL

  1. In the Actions menu, choose Make public via ACL.

    A list of the three objects is displayed.

Click on Make public using ACL

24. Click on Make public

Click on Make public

25. Return to the web browser tab that has the 403 Forbidden message.

Refresh the webpage.

Return to the web browser tab that has the 403 Forbidden message.

# Task 4: Updating the website

You can change the website by editing the HTML file and uploading it again to the S3 bucket.

Amazon S3 is an object storage service, so you must upload the whole file. This action replaces the existing object in your bucket. You cannot edit the contents of an object—instead, the whole object must be replaced.

Make changes to the original index.html and upload again

26. Click on Upload

Click on Upload

27. Click on Add files

Click on Add files

28. Select a file from upload menu

29. Click on Upload

Click on Upload

30. Click on Make public using ACL

Select index.html and use the Actions menu to choose the Make public via ACL option again.

Click on Make public using ACL

31. Click on Make public

32. Return to the web browser tab with the static website and refresh the page.

Return to the web browser tab with the static website and refresh the page.

33. Click on Buckets

Click on Buckets

34. Congratulations, You're Done!

Your static website is now reachable on the internet. Hosting it on Amazon S3 ensures high availability, allowing it to handle substantial traffic without the need for dedicated servers.

Additionally, you have the option to associate your custom domain name with the static website hosted on Amazon S3. This can be achieved by leveraging the Amazon Route 53 Domain Name System (DNS) service in conjunction with Amazon S3.



About

Hosting a Static Website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published