EC2 Instance (EC2)
Core compute workhorse executing backend applications, web servers, API handlers, and batch workers within private or public subnets.
AWS Container Placement
SUBNET, ASG
Summary
Elastic Compute Cloud virtual machines providing resizable compute capacity in the cloud.
When to Use (SAA-C03)
Use for full OS control or long-running processes; place in Private Subnets behind an ALB and pair with ASG for production HA.
Allowed Ingress Connections & Ports
| Source Service | Protocol | Port | Architectural Rationale |
|---|---|---|---|
| ALB | TCP | 80, 8080, 443 | Application Load Balancer health checks and forwarded traffic |
| NLB | TCP | Any TCP Port | Network Load Balancer high-throughput Layer 4 forwarding |
| WEBCLIENT | TCP | 80, 443 | Direct public internet traffic (public subnet only) |
| ADMINCLIENT | TCP | 22 (SSH) | Administrative bastion or jump box SSH shell access |
Allowed Egress Targets & Ports
| Target Service | Protocol | Port | Data Flow Rationale |
|---|---|---|---|
| RDS | TCP | 3306, 5432, 1433 | Relational database queries from application backend |
| S3-ENDPOINT | HTTPS | 443 | Private direct S3 bucket object uploads and downloads |
| NAT | TCP/UDP | 80, 443 | Outbound internet access for OS security patches |
| ELASTICACHE | TCP | 6379 (Redis), 11211 (Memcached) | Low-latency in-memory query caching |
| SSM-ENDPOINT | HTTPS | 443 | Outbound HTTPS connection to AWS Systems Manager endpoints for agent-based Session Manager shell access (0 inbound rules required) |
Key Configuration Parameters & AWS Best Practices
| Parameter | Format / Example | Purpose & Rationale |
|---|---|---|
| Resource Name (label) (Required) | api-server-prod | The logical and display name for this EC2 instance in CloudTracer and the AWS Console. Why: AWS tags instances with Name; required to uniquely identify the instance in deployments and architecture diagrams. |
| Subnet Placement (subnetId / parentId) (Required) | subnet-0abc123 (Public or Private) | The specific VPC Subnet in which the instance Elastic Network Interface (ENI) is bound. Why: An EC2 instance cannot run outside of a VPC subnet because it requires an IP address segment, routing table, and Availability Zone. |
| Instance Type (instanceType) (Required) | t3.medium (2 vCPU, 4 GiB RAM) | Specifies hardware allocations: vCPUs, memory (GiB), network bandwidth, and EBS optimization. Why: AWS hardware schedulers require a fixed instance type to allocate hypervisor slots and compute billing. |
| AMI ID (amiId) (Required) | ami-0c55b159cbfafe1f0 (Amazon Linux 2023 x86_64) | Amazon Machine Image containing the boot operating system, kernel, and software dependencies. Why: AWS hypervisor needs a bootable disk snapshot to initialize root volume filesystems. |
| IAM Instance Profile (iamRole) | arn:aws:iam::123456789012:role/EC2AppRole | Grants the instance temporary STS credentials without storing hardcoded AWS secrets on disk. Why: Best practice: enables secure access to S3, SSM Session Manager, and DynamoDB. |
| Security Group Attachment | sg-web-inbound (TCP 80/443 from ALB) | Stateful firewall rules attached to the instance network interface. Why: Controls which ports (e.g. 80, 443, 22) can reach the server and prevents unauthorized lateral movement. |
| User Data Script | #!/bin/bash
yum update -y && yum install -y docker
systemctl start docker | Automated script run once upon initial instance boot. Why: Used for automated configuration management: installing Docker, cloning Git repos, or setting environment variables. |
| EBS Encryption (storageEncrypted) | true | Encrypts root and attached block storage volumes with AWS KMS. Why: Critical for SOC 2, HIPAA, and PCI-DSS compliance to secure data at rest. |
Practice Labs Using EC2 Instance
Missing Internet Gateway Route
Attach or route default outbound traffic 0.0.0.0/0 to the Internet Gateway in the public route table.…
CLF-02Locked-Out Security Group Ingress
Add an inbound rule allowing TCP port 80 from 0.0.0.0/0 to the web instance Security Group.…
CLF-03Public Database Exposure Vulnerability
Move or configure RDS to be in a private subnet, disable public accessibility, and restrict ingress exclusivel…
CLF-04Single Point of Failure (Single-AZ)
Add a secondary subnet in us-east-1b and front instances with an Application Load Balancer across both Availab…
CLF-06Tight Coupling in Transaction Processing
Decouple the architecture by placing an Amazon SQS queue between the producer and consumer.…
SAA-01FinTech Payment Ledger: $6,750 NAT Gateway S3 Cost Surge
Add an S3 prefix-list destination route in the private route table targeting the S3 Gateway Endpoint.…
Frequently Asked Questions
Where does EC2 Instance live inside an AWS VPC architecture?
Valid container placement: SUBNET, ASG. Core compute workhorse executing backend applications, web servers, API handlers, and batch workers within private or public subnets.
When should I use EC2 Instance on the AWS SAA-C03 exam?
Use for full OS control or long-running processes; place in Private Subnets behind an ALB and pair with ASG for production HA.
Can I simulate EC2 Instance packet routing without an AWS account?
Yes. CloudTracer simulates EC2 Instance along with 53 AWS services directly in your browser and exports production Terraform HCL.