Hosting static website in aws using s3 bucket
Step 1: Create an S3 Bucket
Sign in to AWS Console: Go to the AWS Management Console: https://console.aws.amazon.com/.
Open S3 Console: Navigate to the S3 service.
Create Bucket: Click on the "Create bucket" button.
Bucket Configuration:
Enter a unique name for your bucket (e.g., your-unique-bucket-name).
Choose the region for your bucket.
Click "Next" until you reach the "Permissions" step.
Step 2: Set Bucket Permissions
Manage Bucket Policy:
Select the "Permissions" tab.
Click on "Bucket Policy".
Add the following bucket policy, replacing your-unique-bucket-name with your bucket name:
json
Copy code
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-unique-bucket-name/*"
}
]
}
Save Bucket Policy: Click "Save" after adding the policy.
Step 3: Upload Website Files
Select Bucket: Go back to the "Overview" tab of your S3 bucket.
Upload Files: Click on the "Upload" button to upload your website files (HTML, CSS, JS, images, etc.) into the bucket.
Step 4: Configure Static Website Hosting
Select Bucket: Once your files are uploaded, select your bucket.
Properties: Go to the "Properties" tab.
Static Website Hosting: Click on "Static website hosting".
Choose "Use this bucket to host a website".
For "Index document", enter index.html (or your default HTML file).
Optionally, you can provide an error document for handling 404 errors.
Click "Save".
Step 5: Accessing Your Website
After enabling static website hosting, AWS will provide you with an endpoint URL. You can access your website by navigating to that URL.
Comments
Post a Comment