This guide explains how to build and deploy your Vue frontend application to an AWS S3 bucket and Cloudfront.
- Node.js & npm installed
- AWS CLI installed (Install Guide)
- AWS account with IAM user + access key
- Webapp with a build-ready structure (
npm run build) - Terraform installed (Install Guide)
Legacy workflow (GitHub Actions → S3 + CloudFront, no Terraform)
npm install
npm run buildaws s3 mb s3://your-unique-bucket-name --region eu-central-1Verify the bucket:
aws s3 lsaws s3 sync dist/ s3://your-unique-bucket-name --delete- Go to the AWS Console → S3 → your bucket
- Permissions tab → Turn “Block all public access” →
OFF
Replace your-unique-bucket-name in the JSON below:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-unique-bucket-name/*"
}
]
}- Go to the Properties tab of your bucket
- Scroll down to Static website hosting
- Enable it with the following:
- Index document:
index.html - Error document:
index.html(for Vue router support)
- Go to the AWS Management Console → CloudFront → Create Distribution
- Under Origin, choose:
- Origin domain: Your S3 bucket (e.g.,
your-bucket-name.s3.amazonaws.com) - If the bucket is private, create a new Origin Access Control (OAC) and attach it
- Origin domain: Your S3 bucket (e.g.,
- Viewer Protocol Policy: Redirect HTTP to HTTPS (recommended)
- Cache policy: Use CachingOptimized or create a custom policy
- Default root object:
index.html
Use GitHub Actions to automatically build and deploy your Vue.js app to S3, and then invalidate the CloudFront cache after every push to the master branch.
The deployment workflow is defined in:
.github/workflows/build-and.deploy.yml
- Trigger: Runs automatically on each push to the
masterbranch - Build: Installs dependencies and builds the app with
npm run build - Deploy: Syncs the
dist/directory to the specified S3 bucket (Replace Bucket path with yours) - Invalidate Cache: Issues a CloudFront invalidation to make updates visible immediately (Replace Cloudfront ID with yours)
| Secret Name | Description |
|---|---|
AWS_ACCESS_KEY_ID |
Your IAM user’s AWS Access Key ID |
AWS_SECRET_ACCESS_KEY |
Your IAM user’s Secret Access Key |
node_version |
The Node.js version (e.g., 18) |
Every push to master automatically updates your app in production — no manual steps needed.
