DEV Community

Cover image for How to Deploy a Dynamic Web Application on AWS (Beginner-Friendly Guide)
Oluwatobiloba Oludare
Oluwatobiloba Oludare

Posted on

How to Deploy a Dynamic Web Application on AWS (Beginner-Friendly Guide)

Deploying a dynamic web application on AWS can feel overwhelming at first especially with so many services involved. In this guide, I’ll walk through a simple, practical approach to deploying a dynamic web app using core AWS services.

This is perfect for beginners learning cloud computing and DevOps.

What is a Dynamic Web Application?

Unlike static websites, dynamic web applications:

  • Process user input
  • Connect to databases
  • Generate content in real time

Examples include: Login systems, Dashboards, E-commerce sites

Web apps built with PHP

AWS Services We’ll Use:

To deploy a dynamic web app, we typically need:
🔹 Compute: EC2 – Hosts the application server
🔹 Database: RDS – Stores application data
🔹 Networking & Security : VPC – Network environment and Security Groups
🔹 Storage: S3
🔹 Route 53
🔹 Application Load Balancer
🔹 Auto-scaling group

🪜 Step-by-Step Deployment

1. Select appropriate Region.

2. Create VPC and enable DNS hostname.

3. Create all these Security Groups:

-For ec2 instance connect endpoint (EICE) - No inbound rules- use ssh and limit it to vpc CIDR

-For application load balancer (alb-Sg) - select vpc - allow http & https for anywhere

-For Webserver security group (web-sg)- select vpc - allow http & https, limit to alb-sg - allow ssh, limit to eice.

-Security group to database (db-sg) -- select vpc - Allow MySQL, limit it to webserver-sg - again allow MySQL, limit it dm-sg.

-Security group for data migration (dms) - select vpc- allow ssh, limit it to eice.

4. Create instance connect endpoint in private subnet - select ec2 instance connect endpoint - select vpc - Use eice-sg - select private subnet -private-app-az2

5. Create S3 bucket and upload the application code accordingly.

6. Create IAM Policy

  • Select S3 - grant S3: GetObject & S3: ListBucket. -
    • under Resources - you can limit it using the ARN (but for practice select all) -- Click on add more permission -- select Secret Manager -- grant permission - GetSecretValue & DescribeSecret.

7. Create Role- select Ec2 as use case - select the policy you just created -- name your role.

8. Create Subnet group -- select vpc - select your two AZ -- select your two private Subnets.

9. Create Database RDS-

  • Select Standard create
  • Select MySQL
  • Select the latest mysql database engine version
  • Select the free tier
  • Name your DB instance Identifier
  • Select managed in AWS Secrets Manager
  • Select include previous generation classes
  • Select instance type -- Select your Subnet group
  • Use db-sg as the security group
  • Select your AZ
  • Under configuration give the initial database name.

Now, Migrating data into RDS database:

10. Create Ec2 instance -- select without key pair -- select private subnet private app az2 -- select dms-sg - attach your role under instance profile.

  1. Connect to the ec2 instance using the management console and use the migration script accordingly. Check out for the scripts to migrate data to RDS database here: https://github.com/Oluwatobiloba-Oludare/Dynamic-Web-Application-on-AWS)

  1. After successfully migrating the data, you can terminate the Ec2 instance.

13. Create another ec2 instance in private subnet for webserver -- select without a keypair -- use web-sg -- attach the S3 role under instance profile.

14. Use the Deployment Script accordingly. (Check out the script in this github: https://github.com/Oluwatobiloba-Oludare/Dynamic-Web-Application-on-AWS )

15. Create Target group -- select instance - select VPC -- Under Advance Health check, enter 200,301,302 -- select the instance and include and create.

16. Create Application Load balancer

  • select vpc - select the two AZ in your VPC -- select public subnet for the two AZ -- Use ALB-sg -- Under Listener, select Redirect to URL and select full URL -
  • Add another listener -- select https -- select target group -- under default SSL, select your certificate.

17. Create a Record in our Domain name- use www -- Alias -- select region -- select Application and classic load balancer

Now, use your domain name to check your website on the internet.

Congratulations!

Now, let's be prepare for sudden traffic by setting up our auto-scaling group.

18. Create AMI

  • Go to the ec2 instance running and select actions and select image and templates and select create image -- select Tag image and snapshots together -- under Key, type Name and input your AMI name.

19. Create Launch template
-- select Auto scaling guidelines
-- select My AMIs and select owned by me
-- select t2 micro -- select web sg.

You can terminate the ec2 instance.

20. Create Auto scaling group

  • Select vpc - select the two private app
  • Select attach to an existing load balancer
  • Select target group
  • Select the two Health checks
  • Select the number of scaling you want

✍️ Final Thoughts

Learning AWS becomes easier when you build real projects. Deploying a dynamic web application is one of the best beginner exercises to understand how cloud services work together.

If you are learning AWS, I highly recommend trying this hands-on project.

Follow along for more practical AWS, Docker, and cloud learning posts.

Top comments (0)