Hosting a Static Website
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:
Create a bucket in Amazon S3
Upload content to your bucket
Enable access to the objects within the bucket
Update the website
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."
In the Object Ownership section, select ACLs enabled, then verify Bucket owner preferred is selected.
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.
6. Check I acknowledge that the current settings might result in this bucket and the objects within becoming public.
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
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.
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
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.
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.
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
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.