Host a Website on Amazon S3


Step 1 : Create a bucket in Amazon S3

  • In the AWS Management Console, search for S3.

  • In the AWS Management Console, search for S3.

  • Choose Create bucket.

  • For Bucket name, enter nextwork-website-project-name

Make sure to replace name with your name.

Why can't I just keep 'name' in the bucket name?

An S3 bucket name is globally unique. After you create a bucket, no other AWS account in the entire world can use your bucket's name (unless you delete the bucket).

This also means that when you create your bucket, you need to make sure the bucket's name is unique too.

Object Ownership

💡
ACL disabled vs ACL enabled

ACL Enabled ( Used in this project )

  • What it means: ACLs are a legacy access control mechanism that allows you to grant read/write permissions to specific AWS accounts or predefined groups (e.g., "Everyone" or "Authenticated Users").

  • How it works:

    • You can set bucket-level and object-level permissions using ACLs.

    • ACLs are simpler but less flexible than bucket policies or IAM policies.

    • ACLs are applied in addition to bucket policies and IAM policies.

  • Use case: ACLs are useful for simple use cases where you need to grant access to specific AWS accounts or predefined groups.

  • Example: Granting read access to "Everyone" for a specific object in the bucket.

  • What it means: ACLs are disabled, and permissions are managed only through bucket policies, IAM policies, and access point policies.

  • How it works:

    • You cannot use ACLs to grant permissions at the bucket or object level.

    • All permissions must be managed through policies, which are more flexible and powerful than ACLs.

    • This is the recommended approach by AWS for better security and centralized permission management.

  • Use case: Disabling ACLs is ideal for organizations that want to enforce stricter access control and avoid the complexity of managing multiple permission mechanisms.

  • Example: Using a bucket policy to restrict access to specific IAM users or roles.

FeatureACL EnabledACL Disabled
Permission MechanismUses ACLs + bucket/IAM policiesUses only bucket/IAM policies
GranularityObject-level and bucket-levelBucket-level (object-level via policies)
ComplexitySimpler but less flexibleMore flexible and powerful
SecurityLess secure (legacy mechanism)More secure (recommended by AWS)
Use CaseLegacy applications or simple setupsModern applications, stricter control

Step 2: Upload website content to your bucket

Click on the upload button and upload all your files

Step 3: Configure a static website on Amazon S3

  • Goto the properties tab in the bucket

  • scroll all the way down and you will find “Static website hosting”

  • Click edit > enable > enter your index.html at index document area

  • click on save changes

  • Try to click on the bucket website endpoint url

Errors and resolution

I have encountered error like this

What does this error means:

The content is not publicly available to view. The public view blocking is enabled by default by S3 for security purpose

To solve this :

goto permission tab > edit the Block public access ( bucket settings ) > uptick all > click save changes

Only this will not solve the issue but you have to make whole objects public using “Make public using ACL”

0
Subscribe to my newsletter

Read articles from Narendran Rammudo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Narendran Rammudo
Narendran Rammudo