Deploy a Web Application on Amazon EC2



Follow step-by-step instructions to build and deploy your first web application using Amazon EC2


In this guide, we will take you through creating an Amazon EC2 instance using AWS CDK, and deploying a web application on it. 

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. It provides you with complete control of your computing resources and lets you run on Amazon’s proven computing environment.

What You Will Learn

In this guide, you will learn how to:

  • Create an AWS CDK stack with an Amazon EC2 instance, a security group with inbound access, and an IAM instance profile.
  • Install software packages on the EC2 instance's first launch by creating a user data asset.
  • Configure the software packages after installation using a script downloaded by the user data.
  • Deploying the application using user data.


Before Starting this guide, you will need:

  • An AWS account: if you don't already have one follow the Setup Your Environment getting started guide for a quick overview.
  • CDK Installed: Visit our Setup AWS CDK getting started guide to learn more.

 AWS Experience


 Time to Complete

20 minutes

 Cost to Complete

Free Tier eligible


  • AWS Account with administrator-level access**
  • Recommended browser: The latest version of Chrome or Firefox

[**]Accounts created within the past 24 hours might not yet have access to the services required for this tutorial.


This tutorial is divided into the following short modules. You must complete each module before moving to the next one.

  1. Create Your Infrastructure (10 mins): Using AWS CDK to create an Amazon EC2 instance.
  2. Automate configuration (5 mins): Use the EC2 user data to install all packages, configure them, and deploy the application.
  3. Deploy your stack (5 mins): Bootstrap and deploy the AWS CDK stack.
  4. Clean up: In this last part of the guide you learn how to clean up resources after you are done.

Was this page helpful?

Create Web App