This guide covers CI/CD setup for the Frontend Repository (React).
This guide walks you through setting up AWS CodeBuild and CodePipeline for the Flyora React frontend application.
QuangHieu-lab/Flyora-shopbuildspec.yml file in the repository root (see below)Create a buildspec.yml file in the root of your repository with this content:
version: 0.2
phases:
pre_build:
commands:
- echo "Installing dependencies on `date`"
- npm ci
- echo "Running linter..."
- npm run lint --if-present || echo "No lint script configured"
build:
commands:
- echo "Running tests on `date`"
- npm test -- --watchAll=false --passWithNoTests --coverage || echo "Tests completed"
- echo "Building application on `date`"
- npm run build
- echo "Build completed on `date`"
post_build:
commands:
- echo "Post-build phase started on `date`"
- echo "Checking if build directory exists..."
- ls -la build/
- echo "Build artifacts created successfully"
- echo "Build completed successfully - artifacts ready for deployment"
- echo "Use CodePipeline Deploy stage for S3 deployment"
- echo "CloudFront invalidation will be handled by CodePipeline"
artifacts:
files:
- '**/*'
base-directory: build
name: BuildArtifact
discard-paths: yes
cache:
paths:
- '/root/.npm/**/*'
- 'node_modules/**/*'
Key Points:
npm ci for faster, reliable installs
Before setting up CodeBuild, create an S3 bucket to host your React application:
flyora-frontend-hostingindex.htmlindex.html| Field | Value |
|---|---|
| Project name | flyora-frontend-build |
| Description | Build project for Flyora React frontend |
| Build badge | Leave unchecked |

| Field | Value |
|---|---|
| Source provider | GitHub |
| Repository | Repository in my GitHub account |
| GitHub repository | https://github.com/QuangHieu-lab/Flyora-shop |
| Source version | Leave blank |
| Git clone depth | 1 |
| Primary source webhook events | ⚠️ UNCHECK this |
| Section | Field | Value |
|---|---|---|
| Provisioning | Provisioning model | On-demand |
| Environment image | Managed image | |
| Operating system | Amazon Linux | |
| Runtime(s) | Standard | |
| Image | Latest (e.g., aws/codebuild/amazonlinux2-x86_64-standard:5.0) | |
| Service role | Service role | New service role |
Add these environment variables in CodeBuild:
| Name | Value | Type |
|---|---|---|
AWS_S3_BUCKET | flyora-frontend-hosting | Plaintext |
CLOUDFRONT_DISTRIBUTION_ID | Your CloudFront distribution ID (if using) | Plaintext |
REACT_APP_API_URL | Your backend API URL | Plaintext |


Buildspec:
Use a buildspec fileLogs:
/aws/codebuild/flyora-frontendThe CodeBuild service role needs permissions to access S3 and CloudFront. Add this policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::flyora-frontend-hosting",
"arn:aws:s3:::flyora-frontend-hosting/*"
]
},
{
"Effect": "Allow",
"Action": [
"cloudfront:CreateInvalidation"
],
"Resource": "*"
}
]
}
flyora-frontend-pipelineflyora-frontend-buildflyora-frontend-hosting
After pipeline creation:


Solution: Ensure runtime-versions: nodejs: 18 is set in buildspec.yml
Solution: Check IAM role has S3 permissions (see Step 8)
Solution:
| Resource | Value |
|---|---|
| Pipeline Name | flyora-frontend-pipeline |
| Build Project Name | flyora-frontend-build |
| S3 Bucket | flyora-frontend-hosting |
| Region | Singapore (ap-southeast-1) |
| Source | GitHub (QuangHieu-lab/Flyora-shop) |
| Buildspec | buildspec.yml (in repo root) |
| Logs | CloudWatch: /aws/codebuild/flyora-frontend |
| Item | Cost |
|---|---|
| CodePipeline | $1/month per active pipeline |
| CodeBuild (Free Tier) | 100 build minutes/month for 12 months |
| S3 Storage | ~$0.023/GB/month |
| S3 Requests | Minimal for static hosting |
| CloudFront | Free tier: 1TB data transfer/month |
| Monthly (estimated) | $1-3/month |
✅ Frontend CI/CD Pipeline Configured!
Accomplished:
Your pipeline now: