DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • AWS Agentic AI for App Portfolio Modernization
  • How to Effortlessly Host Your Angular Website on GitHub Pages
  • Angular vs. Flutter for Web App Development: Know Which One Is Best?
  • The Technology Stack Needed To Build a Web3 Application

Trending

  • Full-Text Search Meets the Graph: Apache Lucene Inside Neo4j
  • Beyond the Wall of Charts: How Advanced Observability Displaced the Telemetry Dashboard
  • Designing a Polling Pipeline for Rate-Limited APIs Without Losing Data
  • AI-Powered CI Test Failure Triage

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Deploying an Angular App to AWS S3

Deploying an Angular App to AWS S3

By 
Marouen Helali
·
Mar. 09, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
31.6K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Prerequisites

  • Node.
  • Angular CLI.
  • An activated AWS account.

Getting Started

To get started, use the Angular CLI to generate a new Angular app:

Shell
 




xxxxxxxxxx
1


 
1
ng new



You will be prompted for a name for your app and some configuration choices. Once the CLI has generated all the necessary files for your Angular app, let’s make sure it run fine by executing the following commands:

Shell
 




xxxxxxxxxx
1


 
1
cd <app-name>
2
ng serve



In your favorite browser, navigate to http://localhost:4200. If you used Angular 8, you should see a similar screen to this:

Default Angular landing page
Default Angular landing page

Now that your app is up and running, let’s deploy it to S3. To do so, you will need to log in to your AWS account and go to the S3 console.

Click on the Create Bucket button, follow the steps to give your new bucket a name, and choose an adequate region.

You may also like: Cleaning Up an S3 Bucket With the Help of Athena.

Leave the Configure options as is, and uncheck the Block all public access in the Set permissions section. Now review and create your bucket. Your final screen should look like the image below:

Creating S3 bucket
Creating an S3 bucket

Bucket created

Bucket created

Our new bucket looks great. But it will look even better when we fill it up.

Currently, all we have is a folder with an Angular app. We need to generate the build files, so S3 can understand and serve them. Let’s go back to our Angular app and simply run:

Shell
 




xxxxxxxxxx
1


 
1
ng build --prod



You should see a new dist folder in your project directory. It contains
browser-understandable files that you now need to upload to your bucket.

Go back to S3 to upload the content of your dist folder. Make sure you choose the Grant public read access to this object(s) in the Manage public permissions dropdown.

Leave the Set permissions and Set properties as-is. Then click Upload. Here are some helpful screenshots:

Uploading files
Uploading files

Uploaded files

Uploaded files

Uploaded files

Uploaded files

Now, navigate to Properties and expand Static website hosting.

Static website hosting
Static website hosting

Click Use this bucket to host a website and enter index.html for Index document. Click Save.

Static website hosting
Static website hosting

After saving it, you should see a colored checkmark for Bucket hosting, indicating that it is now enabled. At the top, Endpoint is the link for your freshly deployed Angular app.

After a minute or so, navigate to that link to see the result. Congrats! You just deployed your Angular app to AWS S3!


Further Reading

  • Deploy an Angular App From Visual Studio Code to Azure.
  • Five Things You Probably Didn't Know About Amazon S3.
  • S3 and AWS Java SDK 2.0: Look Before You Leap.
AWS app AngularJS

Published at DZone with permission of Marouen Helali. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • AWS Agentic AI for App Portfolio Modernization
  • How to Effortlessly Host Your Angular Website on GitHub Pages
  • Angular vs. Flutter for Web App Development: Know Which One Is Best?
  • The Technology Stack Needed To Build a Web3 Application

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook