Prerequisites
AWS account
index.html file (You can any use example file on web)
Two parts of hosting
Static website using S3 only
Host website using both S3 and Cloudfront (CDN)
Static website hosting using just S3
Login to ASW Console and search for S3
Click on create bucket and give it a unique name(This should be unique across globe)
Use General Purpose bucket type under General config.
Use ACL Disabled under Object Ownership
Uncheck Block all public access under Block Public Access settings for this bucket and acknowledge.
Let versioning be disabled and by default Encryption type will be 'Server-side encryption with Amazon S3 managed keys (SSE-S3)'
Create a bucket.
Upload a index.html file and save.
Go to properties and under Static website hosting enable static website hosting, set hosting type to Host a static website, index doc to "index.html" and save.
Go to permissions and under Bucket Policy paste the below code and replace <bucketname> with your bucket name.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::<bucketname>/*" } ] }
Now under Permissions> Static website hosting URL will be present, access it to see your website.
Host website using both S3 and Cloudfront (CDN)
This is similar to above with some changes, instead of using S3 URL directly, CDN will be configured to access website which will be useful to deliver the content of the website across world with low latency.
In this case while creating S3 bucket, check to disable all public access (because we are using S3 as a backend and it should be accessed for all except CDN itself)
And under properties> Static website hosting, disable static website hosting.
Now search for CloudFront and create Distribution.
Under origin domain, select S3 bucket with above configured.
Under origin access create a new OAC and select as below.
Under cache behaviour> Viewer protocol policy> select redirect HTTP to HTTPS.
Disable WAF and set default root object to index.html and create distribution.
Copy the policy immediately after CDN is created(may take upto 5min to deploy)
Paste the copied policy json and paste it under S3> Permission> Bucket policy.
Now look for a "Distribution domain name" under CDN you just created under general. (Usually it will be like d1u4wdfgdf2wtaj4.cloudfront.net)
Browse it and you will get you static website hosted in AWS.