AWS Architecture for NestJS Developers
AWS Core Services
The Cloud's Building Blocks
Amazon Web Services, or AWS, provides a massive collection of tools that let you build and run applications on the internet instead of on your own physical hardware. Think of these tools as a set of fundamental building blocks. Just as you'd use different types of bricks to build a house, you use different AWS services to build an application. Each service has a specific job, from running your code to storing your data.
Understanding a few core services is the key to getting started. These are the workhorses of the cloud, handling the essential tasks that nearly every backend system needs: computation, storage, databases, and networking. Let's look at what they do.
Compute Power on Demand
Every application needs a brain, a place where its logic runs. This is called compute. AWS offers a couple of popular ways to get this processing power.
EC2: Your Virtual Server
Think of Amazon Elastic Compute Cloud (EC2) as renting a virtual computer in an AWS data center. You choose its size—how much memory and processing power it has—and you can install whatever software you need on it. You have full control, just like a physical machine. This makes EC2 ideal for applications that need to run constantly, like a traditional web server.
Lambda: Code That Runs Itself
AWS Lambda takes a different approach. Instead of renting a whole server, you just upload a piece of code, called a function. AWS runs that code for you whenever it's needed, or "triggered." You don't manage any servers; this is why it's called serverless computing. Lambda is perfect for small, event-driven tasks, like resizing an image after it's been uploaded. You only pay for the split-seconds your code is actually running.
| Feature | EC2 | Lambda |
|---|---|---|
| Unit | Virtual Server (Instance) | Code Function |
| Management | You manage the server | AWS manages everything |
| Pricing | Pay per hour/second (while running) | Pay per execution & duration |
| Best For | Constant workloads, full control | Event-driven, short tasks |
Storing and Managing Data
Data is the lifeblood of an application. It can be anything from user photos to structured information in a database. AWS provides specialized services for different kinds of data.
Amazon S3
other
Amazon Simple Storage Service (S3) is a service for object storage. It's designed to store and retrieve any amount of data from anywhere. Think of it as a limitless closet for your files.
S3 is not a traditional file system. It stores data as objects within containers called "buckets." It's incredibly durable and scalable, making it perfect for backups, website assets like images and videos, and big data analytics.
For more structured data, you need a database. AWS has two main types.
RDS: The Traditional Database
Amazon Relational Database Service (RDS) makes it easy to set up, operate, and scale a relational database. It supports familiar database engines like MySQL, PostgreSQL, and SQL Server. RDS handles the tedious administrative tasks like patching software and backing up data, so you can focus on your application. It's great for data that fits neatly into tables with rows and columns, like a list of users and their orders.
DynamoDB: The Flexible Database
Amazon DynamoDB is a NoSQL database, meaning it doesn't use the rigid table structure of RDS. It stores data in a key-value format, which is more like a giant dictionary. DynamoDB is built for speed and scale, delivering single-digit millisecond performance no matter how large your dataset grows. This makes it a great fit for applications that need fast, consistent performance at any scale, such as mobile apps, gaming, and IoT devices.
Connecting It All
Finally, you need a way for your services to communicate with each other and with the outside world, all while staying secure.
Amazon VPC
other
Amazon Virtual Private Cloud (VPC) lets you create a logically isolated section of the AWS cloud where you can launch your resources in a virtual network that you define. It gives you complete control over your virtual networking environment.
Think of a VPC as your own private, fenced-off area within the vast AWS landscape. You control who and what can get in or out by defining IP address ranges, creating subnets, and configuring route tables and network gateways. It's the foundation for securing your application's backend.
Once your services are running securely in a VPC, you need a front door for them. That's the job of Amazon API Gateway.
API Gateway is a managed service that lets you create, publish, and secure APIs at any scale. An API (Application Programming Interface) is a set of rules that lets different software applications talk to each other. API Gateway acts as a single entry point for all your backend services, whether they're running on EC2, Lambda, or elsewhere. It handles traffic management, authorization, and monitoring, taking a lot of complex work off your plate.
These core services are the foundation upon which complex, scalable, and powerful applications are built in the cloud.
