Objective: Enable Static Website Hosting on the S3 Bucket
student-management-website-2025to serve the static files (index.html,styles.css,scripts.jsfrom section 6.2) as a static website. This provides an HTTP endpoint (e.g., http://student-management-website-2025.s3-website-us-east-1.amazonaws.com) to access the interface, preparing it for distribution via CloudFront (section 7) with HTTPS and high performance. The interface calls the GET /students, POST /students, and POST /backup API endpoints (section 4.8) using the Invoke URL (e.g., https://abc123.execute-api.us-east-1.amazonaws.com/prod) andStudentApiKey(section 4.2) with CORS (section 4.7).
student-management-website-2025 bucket into a static web server, providing an HTTP endpoint (e.g., http://student-management-website-2025.s3-website-us-east-1.amazonaws.com).index.html, styles.css, scripts.js).index.html as the Index document to display the main page when accessing the root endpoint.student API (stage prod, section 4.8) to:
studentData and send a confirmation email via SES.student-backup-20250706 (section 2.4, 6.5) and send notification emails via SES.s3:GetObject) for CloudFront to retrieve the content.index.html as the Index document:
index.html is the main file containing the interface (form, table, functional buttons) uploaded in section 6.2.index.html as the default page.You need to complete section 6.1 (create the student-management-website-2025 bucket), section 6.2 (upload index.html, styles.css, scripts.js), section 5 (build the web interface), section 4.1 (create the student API), section 4.2 (create the StudentApiKey), section 4.3 (create the StudentUsagePlan), section 4.4 (create the GET /students method), section 4.5 (create the POST /students method), section 4.6 (create the /backup resource and POST /backup method), section 4.7 (enable CORS), section 4.8 (deploy the API to the prod stage), section 4.9 (link the StudentApiKey to StudentUsagePlan), section 3 (create Lambda functions getStudentData, insertStudentData, BackupDynamoDBAndSendEmail, DynamoDB table studentData, student-backup-20250706 bucket, SES email verification). Ensure your AWS account has s3:PutBucketWebsite permissions and the AWS region is us-east-1.
Access the AWS Management Console
student-management-website-2025 bucket, student API, Lambda functions (getStudentData, insertStudentData, BackupDynamoDBAndSendEmail), DynamoDB studentData, student-backup-20250706 bucket, and SES. The region is displayed in the top right corner of the AWS Console.
Figure 1: AWS Console Interface with the S3 search bar.Select the student-management-website-2025 Bucket
student-management-website-2025 bucket (created in section 6.1).us-east-1) and refresh the page.student-management-website-20250706-abc123).
Figure 2: Select the student-management-website-2025 bucket.Access the Properties Tab
Figure 3: Properties Tab and Static Website Hosting Section.Edit Static Website Hosting
index.html, styles.css, scripts.js have been uploaded to the bucket (section 6.2), as Static Website Hosting requires the index.html file to function correctly.
Figure 4: Click Edit in Static Website Hosting.Configure Static Website Hosting
index.html (the main file of the web interface, containing the form and student table).
index.html as the default page.index.html to redirect any errors (e.g., 404 Not Found) back to the main page.error.html file (section 6.2) and enter the file name here.index.html.
Figure 5: Configure Static Website Hosting.Save Changes
Figure 6: Click Save Changes.http://student-management-website-2025.s3-website-us-east-1.amazonaws.com.
Figure 7: Status Message and Bucket Website Endpoint.Test Static Website Hosting
Open your browser and go to the Bucket website endpoint (e.g., http://student-management-website-2025.s3-website-us-east-1.amazonaws.com).
Expected result:
styles.css and scripts.js files should load correctly, and the interface should use Tailwind CSS and Poppins font as expected.
Figure 8: Web Interface Displayed via S3 Endpoint.Note:
Error Handling:
s3:GetObject is allowed publicly.index.html is uploaded to the bucket (section 6.2) and is located in the root directory.index.html for styles.css and scripts.js (e.g., , ).s3:PutBucketWebsite permissions.| Factor | Details |
|---|---|
| Security | Currently, the bucket uses public access (s3:GetObject). Use CloudFront Origin Access Identity (OAI) (section 6.4) to restrict direct access to S3. Avoid embedding StudentApiKey in scripts.js; use AWS Secrets Manager or CloudFront Functions: function handler(event) { var request = event.request; request.headers[‘x-api-key’] = { value: ‘xxxxxxxxxxxxxxxxxxxx’ }; return request; } |
| Optimization | Ensure styles.css, scripts.js are compressed (section 6.2). Enable S3 Access Logs: In S3 > student-management-website-2025 > Properties > Server access logging, select Enable, and specify a log bucket (e.g., student-web-logs-20250706). Use AWS CLI: aws s3api put-bucket-website –bucket student-management-website-2025 –website-configuration ‘{“IndexDocument”:{“Suffix”:“index.html”},“ErrorDocument”:{“Key”:“index.html”}}’ |
| System Integration | Configure Bucket Policy (section 6.4) to allow CloudFront to retrieve the content. Create a CloudFront distribution (section 7) with the Origin as the Bucket website endpoint, Default root object: index.html, Viewer protocol policy: Redirect HTTP to HTTPS. Update CORS in API Gateway (section 4.7) with Access-Control-Allow-Origin: https://d12345678.cloudfront.net. |
| Integration Testing | Access the Bucket website endpoint to test the interface. After configuring CloudFront, access the CloudFront URL (https://d12345678.cloudfront.net) and check: POST /students (save records, send SES email), GET /students (display table), POST /backup (create file in student-backup-20250706, send email). Use Developer Tools > Network to test API requests. |
| Error Handling | 403 Forbidden: Check the Bucket Policy (section 6.4) and Block all public access (section 6.1). 404 Not Found: Verify index.html is in the root folder, paths in index.html are correct (, ). Incorrect Interface: Check Developer Tools > Console. AccessDenied: Check IAM role (s3:PutBucketWebsite). |
Best Practice Tip: Test the S3 endpoint before integrating CloudFront. If you encounter CORS errors, verify the CORS configuration in API Gateway (section 4.7). Use AWS CLI to automate configuration.
The Static Website Hosting feature has been enabled on the student-management-website-2025 bucket, providing an endpoint to serve the web interface. The bucket is ready to integrate with CloudFront (section 7) to support HTTPS.
Next step: Proceed to Configure Bucket Policy for Public Access to continue configuring!