- Newest
- Most votes
- Most comments
Yes, a website built with Angular can run on AWS S3 as a static website. Angular applications, when built for production using the Angular CLI (ng build --prod), generate static assets including HTML, CSS, and JavaScript files. These compiled files can be uploaded to an S3 bucket that's configured for static website hosting.
To host an Angular application on S3, you would:
- Build your Angular application for production
- Create an S3 bucket
- Configure the bucket for static website hosting by setting the index document (typically to "index.html") and an error document
- Set appropriate bucket policies to allow public access to your website files
- Upload all the built files from your Angular application to the S3 bucket
For single-page applications like Angular, you'll want to ensure your error document is set to "index.html" as well, so that client-side routing works correctly when users refresh the page or access deep links directly.
S3 static website hosting is a good choice for Angular applications because it's cost-effective, highly available, and scalable. Since Angular runs entirely in the browser after the initial load, it works perfectly with the static hosting model that S3 provides.
Sources
Amazon S3 examples using SDK for JavaScript (v3) - AWS SDK Code Examples
Community | Static S3 Website | S01 E04 | Build On Weekly
Community | Hosting my Static Website in an AWS S3 Bucket — Part 1
Use PutBucketWebsite with an AWS SDK or CLI - Amazon Simple Storage Service
You can run any static website on AWS S3, does not matter whether it's plain HTML, Javascript, or Angular or React.
Relevant content
asked 3 years ago
asked a year ago
