Objective: Upload the static web interface files (
index.html
,styles.css
,scripts.js
from section 5) to the S3 Bucketstudent-management-website-2025
(created in section 6.1) in preparation for enabling Static Website Hosting (section 6.3) and serving the content via CloudFront (section 7). These files form the interface of the Student Data Management application, allowing users to input, view, and back up student data via the GET /students, POST /students, and POST /backup API endpoints (section 4.8) with API Key security (StudentApiKey
, section 4.2) and CORS (section 4.7).
index.html
: The structure of the interface with an input form, student display table, and functional buttons (Save, View, Backup).styles.css
: Customizes the interface with Tailwind CSS, Poppins font, color gradients, and animations.scripts.js
: The logic for calling the API using jQuery, making requests to the Invoke URL (e.g., https://abc123.execute-api.us-east-1.amazonaws.com/prod
) with the x-api-key: <StudentApiKey>
header.student-management-website-2025
bucket:
s3:GetObject
) in the Bucket Policy (section 6.4) to allow CloudFront to retrieve the content.student
API (stage prod
, section 4.8) to perform the following functions:
studentData
and send a confirmation email via SES.student-backup-20250706
(section 2.4, 6.5) and send notification emails via SES.https://d12345678.cloudfront.net
).You need to complete section 6.1 (create the student-management-website-2025
bucket), section 5 (build the web interface with index.html
, styles.css
, scripts.js
), 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
and associate with the student
API in the prod
stage), section 3 (create Lambda functions getStudentData
, insertStudentData
, BackupDynamoDBAndSendEmail
, DynamoDB table studentData
, student-backup-20250706
bucket, SES email verification). Ensure your AWS account has permissions to access S3 (s3:PutObject
) 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.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
).student-management-website-2025
.student-management-website-2025
bucket.Open the Upload Interface
student-management-website-2025
bucket, click the Upload button (usually located at the top right).Prepare and Drag and Drop Files to Upload
index.html
: The interface with forms, tables, and functional buttons, using Tailwind CSS and jQuery.styles.css
: Custom styles with Poppins font, gradients, and responsive effects.scripts.js
: The logic for calling the API with the Invoke URL (e.g., https://abc123.execute-api.us-east-1.amazonaws.com/prod
) and StudentApiKey
(e.g., xxxxxxxxxxxxxxxxxxxx
).student-web-files/
) for easier management.scripts.js
and verify that API_ENDPOINT
and API_KEY
have been replaced with the Invoke URL (section 4.8) and StudentApiKey
(section 4.2).const API_ENDPOINT = 'https://abc123.execute-api.us-east-1.amazonaws.com/prod';
const API_KEY = 'xxxxxxxxxxxxxxxxxxxx';
API_KEY
directly; see the Note for using AWS Secrets Manager or CloudFront Functions.index.html
locally in your browser to ensure the interface displays correctly before uploading.index.html
, styles.css
, scripts.js
files from your local folder to the upload area.css/
, js/
) to ensure a simple path (e.g., https://student-management-website-2025.s3-website-us-east-1.amazonaws.com/index.html
).css
, js
) and upload the respective files, but update the paths in index.html
:
<link rel="stylesheet" href="/css/styles.css">
<script src="/js/scripts.js"></script>
Upload the Files to the Bucket
index.html
, styles.css
, scripts.js
in the file list.Check the Upload Status
index.html
, styles.css
, scripts.js
.s3:PutObject
permissions.us-east-1
).student-management-website-2025
bucket.Factor | Details |
---|---|
File Structure | - Upload the files directly to the root folder for a simple path (e.g., /index.html , /styles.css , /scripts.js ). - If using subfolders (css/ , js/ ), update the paths in index.html and verify when enabling Static Website Hosting (section 6.3). |
Security | - Avoid embedding StudentApiKey directly in scripts.js . Use AWS Secrets Manager or CloudFront Functions to add the x-api-key header: ```javascript // Example with CloudFront Functions function handler(event) { var request = event.request; request.headers[‘x-api-key’] = { value: ‘xxxxxxxxxxxxxxxxxxxx’ }; return request; } - After uploading, configure the Bucket Policy (section 6.4) to manage the s3:GetObject permission instead of relying on public-read ACL. - Use CloudFront Origin Access Identity (OAI) (section 7) for better security, restricting direct access to S3. |
Optimization | - File Compression: Minimize styles.css and scripts.js (use UglifyJS or CSSNano) to reduce loading time. - Content Check: Open index.html locally in the browser to ensure the interface displays correctly before uploading. - Use AWS CLI: Upload files faster with the command: bash <br> aws s3 cp student-web-files/ s3://student-management-website-2025/ --recursive <br> - S3 Versioning: Enabled in section 6.1, ensuring you can recover from errors when uploading the wrong file. |
System Integration | - After uploading the files, enable Static Website Hosting (section 6.3) to get the endpoint (e.g., http://student-management-website-2025.s3-website-us-east-1.amazonaws.com ). - Configure Bucket Policy (section 6.4) to allow CloudFront to retrieve the content. - Integrate with CloudFront (section 7) to serve the interface via HTTPS and improve loading speeds. - Ensure CORS in API Gateway (section 4.7) supports requests from the CloudFront domain (e.g., https://d12345678.cloudfront.net ). |
Integration Testing | - Verify the files in S3 > Buckets > student-management-website-2025 > Objects. - After enabling Static Website Hosting (section 6.3), access the S3 endpoint (e.g., http://student-management-website-2025.s3-website-us-east-1.amazonaws.com ) to test the interface. - Expected result: The interface should display with forms, tables, and functional buttons. - Note: API requests may encounter CORS errors if CloudFront has not been configured yet; this will be fixed in section 7. - After integrating with CloudFront, test the following functions: - POST /students: Save records to DynamoDB studentData and send an email via SES. - GET /students: Display data in the table. - POST /backup: Create files in student-backup-20250706 and send notification emails. |
Error Handling | - 403 Forbidden: Check the s3:PutObject permission and Bucket Policy (section 6.4). - Files not displaying: Verify the files were uploaded to the correct bucket and root folder. - Interface errors: Check paths in index.html (e.g., <link href="styles.css"> , <script src="scripts.js"> ) and the browser’s log (Developer Tools > Console). |
Best Practice Tip: Before uploading, test the interface locally with
npx serve
or a static server to ensure the files work correctly. Use AWS CLI to upload faster if you have multiple files. After uploading, verify the file list in the bucket and proceed with section 6.3 (enable Static Website Hosting).
The index.html
, styles.css
, and scripts.js
files have been uploaded to the student-management-website-2025
bucket, ready for enabling Static Website Hosting (section 6.3) and integrating with CloudFront (section 7) to serve the web interface.
Next step: Proceed to Enable Static Website Hosting to continue configuring!