AWS Interview Q&A

1. What is EC2 and its main use?

EC2 provides resizable virtual servers in the cloud. It's used to run applications, host websites, and deploy services quickly.

2. Scenario: Your EC2 instance is running slow. How do you troubleshoot?

Check CPU, memory, disk usage in CloudWatch, verify instance type, review running processes, and consider scaling vertically or horizontally.

3. What is the difference between stopping and terminating an EC2 instance?

Stopping preserves the instance and attached EBS volumes. Terminating deletes the instance and associated resources.

4. Scenario: How do you automatically scale EC2 instances based on CPU usage?

Use Auto Scaling Groups with CloudWatch alarms to scale out/in instances dynamically based on CPU metrics.

5. Scenario: Your EC2 instance cannot connect to the internet. What do you check?

Check security groups, route tables, network ACLs, and public IP assignment. Ensure the subnet is in a VPC with an internet gateway.

6. What is an AMI?

An Amazon Machine Image (AMI) is a template containing OS and software configuration to launch EC2 instances.

7. Scenario: You want to reduce EC2 costs. What options are available?

Use Reserved Instances, Spot Instances, right-size instance types, or auto-scaling policies.

8. What are instance types in EC2?

Instance types define compute, memory, storage, and networking capacity; examples include t3.micro, m5.large, c5.xlarge.

9. Scenario: How do you connect to an EC2 instance securely?

Use SSH with key pairs, ensure security group allows inbound traffic, and consider using Session Manager for no-bastion access.

10. Scenario: Your EC2 instance disk is full. How to fix it?

Increase EBS volume size, remove unnecessary files, or attach additional EBS volumes.

11. What is the difference between EBS and instance store?

EBS provides persistent storage that survives instance termination, while instance store is temporary and lost when the instance stops.

12. Scenario: You need high availability for your EC2 instances. How?

Deploy instances across multiple Availability Zones in an Auto Scaling Group behind an Elastic Load Balancer.

13. What are security groups?

Virtual firewalls for EC2 instances controlling inbound and outbound traffic at the instance level.

14. Scenario: How do you automate EC2 backups?

Use Amazon Data Lifecycle Manager or schedule snapshots using AWS CLI or Lambda.

15. What is EC2 metadata?

Metadata provides information about the instance like instance ID, type, region, and attached volumes, accessible from inside the instance.

16. Scenario: Your instance is terminated accidentally. How do you recover?

Use AMI snapshots or EBS volume snapshots to launch a new instance with the previous configuration.

17. What is Elastic IP?

A static IPv4 address designed for dynamic cloud computing, which can be associated with an EC2 instance.

18. Scenario: EC2 instance CPU is underutilized. What to do?

Downsize instance type, consolidate workloads, or use Spot instances for cost efficiency.

19. What is placement group in EC2?

Placement groups determine how instances are placed on underlying hardware for high performance or low-latency networking.

20. Scenario: You need multiple applications on a single EC2 instance. How do you isolate them?

Use Docker containers or separate processes with user-level permissions for isolation.

21. What is user-data in EC2?

A script or commands that run on instance launch to perform automated setup or software installation.

22. Scenario: You want zero downtime deployment for EC2-based app. How?

Use blue-green deployment or deploy behind an Elastic Load Balancer with multiple instances.

23. What is Elastic Load Balancer?

A service that automatically distributes incoming application traffic across multiple targets like EC2 instances.

24. Scenario: EC2 instance loses network connectivity. What to check?

Verify security group, network ACLs, route tables, and VPC configuration.

25. Scenario: Your EC2 instance is compromised. How do you respond?

Isolate the instance, create an AMI snapshot for forensics, rotate IAM credentials, and redeploy a clean instance.