Ankit KanojiyaBeginner
Evergreen guide by Ankit Kanojiya · Beginner · DevOps & Cloud
AWS Core Services Map: EC2, S3, IAM, VPC
The four AWS services every other one depends on, how they fit together, and the interview questions that come up about them.
- aws
- cloud
- devops
- ec2
- s3
- iam
The AWS console lists well over two hundred services, and the first time you open it the question is where to even start. For most jobs, and for almost every interview question about AWS, four services do the heavy lifting: EC2 runs your code, S3 stores your files, IAM decides who is allowed to do what, and VPC is the private network all of it sits in. Learn how those four fit together and the rest of AWS becomes variations on the same ideas.
The problem these four solve
Before cloud, running a web app meant buying a server, racking it somewhere, giving it a network connection, and handing out logins to the people who needed access. AWS splits that into separately billable pieces. EC2 is the server. S3 is the disk you would have attached for files that outlive any one machine. VPC is the network cable, switch and firewall. IAM is the login system, except it covers every API call, not just SSH.
Each piece scales on its own: one small EC2 instance can write to a bucket holding 50 TB, and two hundred instances can share one VPC.
EC2: the machine
Elastic Compute Cloud gives you a virtual machine, called an instance, with a CPU, memory, disk and an operating system image (an AMI). You pick an instance type that encodes the hardware: t3.micro is a small, cheap, burstable box; m-family is general purpose; c-family is compute-heavy; r-family is memory-heavy. The first letter is the family, the number is the generation, the suffix is the size.
The mental model to keep: an instance is disposable. Its root disk (an EBS volume) can be set to vanish when the instance terminates, and most production setups treat instances as cattle. Anything that must survive goes to S3, EBS snapshots, or a database.
Things attached to an instance that interviewers ask about: a security group (a stateful firewall for the instance; allow port 443 in, and the reply traffic is allowed out automatically), a key pair for SSH, an IAM role (more on that below), and user data, a script that runs on first boot to install your app.
Pricing has four shapes: On-Demand (pay by the second, no commitment), Reserved or Savings Plans (commit for one or three years, pay less), Spot (bid on spare capacity at a steep discount, but AWS can take it back with two minutes' notice), and Dedicated Hosts for licensing or compliance reasons. Spot plus auto scaling is the standard answer to "how would you run a batch job cheaply".
S3: the file store
Simple Storage Service is object storage. You create a bucket, whose name is globally unique across all AWS accounts, and put objects into it under a key such as invoices/2026/11/inv-1042.pdf. There are no real folders; the slashes are part of the key, and the console just draws them as folders.
Why not a normal filesystem? Because S3 is built for durability and scale rather than speed. AWS designs it for 99.999999999% durability (eleven nines), which is their way of saying objects effectively do not get lost, and a single bucket can hold any number of objects of up to 5 TB each. You talk to it over HTTPS, not through a mount point, which is why it suits static websites, backups, logs, uploads, and data lakes, and does not suit a database's data files.
Storage classes trade price for access speed: Standard for frequently read data, Standard-IA and One Zone-IA for data read rarely, Glacier tiers for archives where retrieval can take minutes to hours, and Intelligent-Tiering, which moves objects between classes based on access patterns. Lifecycle rules automate the moves ("after 90 days, move to Glacier; after 7 years, delete").
The two S3 features that show up in system design rounds: versioning, which keeps every overwrite so you can roll back, and pre-signed URLs, which let a user upload or download one object directly for a limited time without your server proxying the bytes.
IAM: who may do what
Identity and Access Management is the service people skip and then get burned by. Every API call in AWS, from launching an instance to listing a bucket, is checked against IAM. The pieces:
A user is a person or a script with long-lived credentials. A group is a set of users sharing permissions. A role is an identity with no permanent credentials that something assumes temporarily: an EC2 instance, a Lambda function, a user from another account. A policy is a JSON document that says which actions are allowed or denied on which resources.
A minimal policy looks like this:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::app-uploads/*"
}]
}
Attach that to a role, attach the role to an EC2 instance, and the app on that instance can read and write objects in app-uploads with no access keys stored anywhere. The SDK fetches temporary credentials from the instance metadata service automatically. This is the correct answer whenever an interviewer asks how an application on EC2 should authenticate to S3; "put the access key in an environment variable" is the wrong one.
Two evaluation rules to remember. Everything is denied by default, so you only ever add Allow statements to open things up. And an explicit Deny anywhere wins over any Allow, which is how organisations enforce guardrails such as "no one may delete this bucket, whatever other permissions they hold".
VPC: the network
A Virtual Private Cloud is an isolated network inside a region, defined by a CIDR block such as 10.0.0.0/16. Inside it you carve subnets, each tied to one availability zone. A subnet is public if its route table sends 0.0.0.0/0 to an internet gateway; otherwise it is private. Instances in a private subnet reach the internet, for package updates say, through a NAT gateway sitting in a public subnet, but nothing on the internet can start a connection to them.
The usual layout for a web app: a load balancer in public subnets across two availability zones, application instances in private subnets behind it, and the database in private subnets with a security group that only accepts traffic from the app tier's security group. The two-AZ part is what makes "highly available" mean something; one data centre can go down and the app keeps serving.
VPC has two firewalls, and interviewers like the difference. Security groups are attached to instances, are stateful, and only have allow rules. Network ACLs are attached to subnets, are stateless (you must allow the reply traffic explicitly), and support deny rules. Most teams rely on security groups and leave the default NACL alone.
A worked example: a photo-upload app
A user opens your site. The request reaches an Application Load Balancer in a public subnet, which forwards it to an EC2 instance in a private subnet. The user picks a photo. Rather than send 8 MB through your server, the app asks S3 for a pre-signed PUT URL for the key uploads/user-4411/IMG_2031.jpg, valid for five minutes, and returns it to the browser, which uploads straight to the bucket. The instance can request that URL because its IAM role allows s3:PutObject on uploads/* and nothing else. A lifecycle rule moves originals to Standard-IA after 30 days. The database holding user records lives in another private subnet, reachable only from the app tier's security group on port 5432.
Trace the four services through that paragraph: EC2 ran the code, S3 held the file, IAM authorised the signed URL, VPC kept the database off the internet.
Interview questions you should expect
What is the difference between a security group and a network ACL? (Stateful vs stateless, instance vs subnet, allow-only vs allow-and-deny.)
How should an app on EC2 get access to S3? (An IAM role attached to the instance, never hard-coded keys.)
What happens to data on an EC2 instance when it is terminated? (Root EBS volume is deleted by default; anything you need must be on S3, a persistent EBS volume, or a database.)
When would you use Spot instances? (Fault-tolerant, interruptible work: batch jobs, CI runners, data processing; not a primary database.)
Why is an S3 bucket name globally unique? (Bucket names form part of a public DNS hostname, so two accounts cannot share one.)
How do you make a private instance reach the internet? (Route its subnet's outbound traffic through a NAT gateway in a public subnet.)
What does "eleven nines of durability" mean in practice? (AWS stores copies across multiple facilities in a region; it is a durability figure, not an availability one, and the two are separate numbers.)
Go deeper
Create a free-tier account and build the layout above by hand once, in the console, before you touch Terraform; the mistakes you make placing subnets and route tables are the lessons. Read the IAM policy evaluation logic page in the AWS docs, because deny-overrides-allow has edge cases with resource policies and permission boundaries. Then look at what sits on top of these four: Lambda (functions instead of instances), RDS (managed databases in your VPC), CloudFront (a CDN in front of S3), and Auto Scaling groups (EC2 that adds and removes instances for you).
Instance names, storage classes and free-tier limits change, so check the AWS pricing and docs pages for current numbers before you quote any in an interview.