Introduction to AWS Monitoring and Logging
In this blog I will tell you how you can host a static web application on AWS S3.
Here’s a step-by-step guide to help you set it up:
Step 1: Create an S3 Bucket
1. Log in to the AWS Management Console.
2. Navigate to the S3 service.
3. Click on "Create bucket."
- Bucket name: Choose a unique name (e.g., my-static-website
).
- Region: Select your preferred region.
4. Configure options (optional):
- Leave most settings as default unless you have specific requirements.
5. Set permissions:
- Under "Block Public Access settings for this bucket," make sure to uncheck "Block all public access" if you want your site to be publicly accessible.
6. Review and Create bucket.
Step 2: Upload Your Website Files
1. Select the newly created bucket.
2. Click on the "Upload" button.
3. Add files and folders: Upload your static web files (HTML, CSS, JS, images).
4. Set permissions: Ensure your files are publicly accessible by setting them to be public or using bucket policies (detailed in Step 4).
5. Click on "Upload" to complete the upload process.
Step 3: Configure the Bucket for Static Website Hosting
1. Go to the bucket properties.
2. Select "Static website hosting."
3. Choose "Use this bucket to host a website."
4. Specify the index document (e.g., index.html
).
- Optionally, specify an error document (e.g., error.html
).
5. Save changes.
Step 4: Set Bucket Policy for Public Access
1. Navigate to the "Permissions" tab.
2. Click on "Bucket Policy."
3. Add the following policy, replacing YOUR-BUCKET-NAME
with your actual bucket name:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*" } ] }
4. Save the bucket policy.
Step 5: Access Your Website
1. Get the Endpoint URL:
- Go to the "Static website hosting" section in your bucket properties.
- Note the "Endpoint" URL. This is the URL to access your static website.
Your static website should now be live and accessible at the S3 endpoint URL provided.
Subscribe to my newsletter
Read articles from Jatin Shastri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by