In this section, you will set up Amazon S3 for static assets, CloudFront for content distribution, and AWS Amplify to host the React frontend application.

Go to S3 Console → Create bucket
General configuration:
daivietblood-assets-{your-account-id}Object Ownership:
Block Public Access settings:
Bucket Versioning:
Default encryption:
Click Create bucket
After creating CloudFront distribution (Part 2), update bucket policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowCloudFrontAccess",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::daivietblood-assets-{your-account-id}/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::{account-id}:distribution/{distribution-id}"
}
}
}
]
}
Create folder structure:
/images
/blood-types
/icons
/banners
/documents
Upload sample images for the application
Go to CloudFront Console → Create distribution
Origin settings:
daivietblood-s3-origindaivietblood-oacDefault cache behavior:
Settings:
index.htmlClick Create distribution
Important: Copy the bucket policy provided and update your S3 bucket policy
After distribution is deployed (takes 5-10 minutes):
Copy the Distribution domain name:
https://d1234567890.cloudfront.net
Test accessing an asset:
https://d1234567890.cloudfront.net/images/logo.png
npx create-react-app daivietblood-frontend
cd daivietblood-frontend
npm install axios react-router-dom
.env file:REACT_APP_API_URL=https://xxxxxxxxxx.execute-api.ap-southeast-1.amazonaws.com/prod
REACT_APP_ASSETS_URL=https://d1234567890.cloudfront.net
src/services/api.js):import axios from 'axios';
const API_URL = process.env.REACT_APP_API_URL;
export const getUsers = async () => {
const response = await axios.get(`${API_URL}/users`);
return response.data;
};
export const createUser = async (userData) => {
const response = await axios.post(`${API_URL}/users`, userData);
return response.data;
};
export const getEmergencyRequests = async () => {
const response = await axios.get(`${API_URL}/emergency-requests`);
return response.data;
};
export const createEmergencyRequest = async (requestData) => {
const response = await axios.post(`${API_URL}/emergency-requests`, requestData);
return response.data;
};
Go to AWS Amplify Console → Create new app
Choose source:
Add repository branch:
Configure build settings:
daivietblood-frontendBuild settings (amplify.yml):
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Environment variables:
REACT_APP_API_URL and REACT_APP_ASSETS_URLClick Save and deploy
Access Amplify URL:
https://main.d1234567890.amplifyapp.com
Test functionality: