
Deployment of Single Page Application on AWS
Using terraform for prepare infrastructure for single page application on aws
Published Feb 12, 2025
Last Modified Feb 13, 2025
- Architecture Overview
- S3 Configuration
- ACM Configuration
- CloudFront Configuration
- Route53 Configuration
- Key Integration Points
- Deployment Verification
GitHub Source Code: https://github.com/igorgorovoy/spa-app-aws.git
While preparing for the AWS Solutions Architect exam, I decided to take a deep dive into deploying a Single Page Application (SPA) on AWS. This article is a result of my research and hands-on experience setting up a scalable, secure, and cost-effective architecture. If you're looking for a structured way to host your SPA using AWS services, you're in the right place!
To deploy a Single Page Application (SPA), I used the following AWS services:
- S3: Stores static files (HTML, CSS, JS)
- CloudFront: CDN for fast content delivery
- Route53: DNS management
- ACM: SSL/TLS certificates

- Go to: AWS Console → S3
- Create a new bucket
- Name: spa-app-aws.example.com
- Block all public access
Terraform code:
One key takeaway from my exam preparation was that CloudFront requires SSL/TLS certificates from AWS Certificate Manager (ACM) in the us-east-1 region. This can be a common pitfall if not configured correctly.
Via AWS Console:
1. AWS Console → Certificate Manager
2. Request a certificate
3. Specify domains:
example.com
and *.example.com
Terraform code:
Setting up CloudFront properly was a crucial part of my learning experience. I had to ensure that all requests were routed correctly and that error handling was configured to support SPA routing.
Finally, linking everything together with Route 53 was a satisfying step, as it provided the final touch for ensuring smooth domain resolution.
- Origin Access Control (OAC) ensures secure access from CloudFront to S3.
- Certificate must be in us-east-1 region for CloudFront integration.
- Alias record in Route53 must point to the CloudFront distribution.
- Upload all SPA files to the S3 bucket
- Check file structure
- Wait for the CloudFront distribution to deploy (Status: Deployed)
- Check availability via CloudFront URL
- Ensure the certificate is active
- Verify HTTPS connection
- Open the main URL
- Test different SPA routes
- Refresh pages on different routes
If you prefer to use Cloudflare for DNS management instead of Route 53, follow these additional steps: 1. Add your domain to Cloudflare and update your domain’s nameservers to Cloudflare’s provided ones.
2. Create a CNAME record in Cloudflare pointing your domain (e.g.,
example.com
) to the CloudFront distribution domain. 3. Ensure SSL/TLS settings in Cloudflare are set to "Full" or "Full (Strict)" to maintain proper HTTPS connections.
4. Disable proxy mode (orange cloud) for the CNAME record to avoid conflicts with CloudFront.
5. Optionally, configure Page Rules in Cloudflare to optimize caching and performance for your SPA.
By following these steps, you can seamlessly integrate Cloudflare with your AWS-hosted SPA while benefiting from Cloudflare’s additional security and performance features.
By going through this hands-on experience, I feel much more confident in setting up a production-ready SPA architecture on AWS. If you're preparing for the Solutions Architect exam, I highly recommend practicing deployments like this to solidify your understanding. Happy learning!