How to deploy Angular app to AWS

AWS S3 combined with CloudFront provides scalable, cost-effective hosting for Angular applications with global CDN distribution and high availability. As the creator of CoreUI, a widely used open-source UI library, I’ve deployed Angular applications to AWS infrastructure throughout my 11 years of Angular development. The most reliable approach is building the Angular app for production and uploading the dist folder to an S3 bucket configured for static website hosting. This method enables automatic scaling, global edge distribution, and pay-as-you-go pricing without managing servers.

Build your Angular app and upload the dist folder to an S3 bucket configured for static hosting.

# Build Angular app for production
ng build --configuration production

# Install AWS CLI if not already installed
# Then configure AWS credentials
aws configure

# Create S3 bucket
aws s3 mb s3://your-app-name

# Enable static website hosting
aws s3 website s3://your-app-name --index-document index.html --error-document index.html

# Upload build files
aws s3 sync dist/your-app-name s3://your-app-name --delete

# Set bucket policy for public read access
aws s3api put-bucket-policy --bucket your-app-name --policy '{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "PublicReadGetObject",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::your-app-name/*"
  }]
}'

Here ng build creates optimized production files in the dist directory. The aws s3 mb command creates a new S3 bucket. The aws s3 website command enables static website hosting with index.html as both the index and error document, ensuring Angular Router handles all routes client-side. The aws s3 sync command uploads all files, using –delete to remove outdated files from previous deployments. The bucket policy grants public read access so users can access your application.

Best Practice Note:

This is the AWS deployment strategy we use for CoreUI Angular applications requiring enterprise-grade infrastructure. Add CloudFront distribution in front of S3 for better performance and HTTPS support, enable S3 versioning for rollback capabilities, and use AWS CodePipeline for automated deployments from Git repositories on every commit.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
How to Open Link in a New Tab in HTML?
How to Open Link in a New Tab in HTML?

Understanding the Difference Between NPX and NPM
Understanding the Difference Between NPX and NPM

How to get the last element in an array in JavaScript
How to get the last element in an array in JavaScript

How to capitalize the first letter in JavaScript?
How to capitalize the first letter in JavaScript?

Answers by CoreUI Core Team