Introduction to AWS for Beginners

6.76K 0 0 0 0

📘 Chapter 3: Hands-On With AWS – Your First Deployments

🔍 Overview

In this chapter, we’ll put AWS into action. You’ve learned the theory and explored the core services—now it’s time to build real-world projects step-by-step using the AWS Free Tier. This chapter is designed for absolute beginners to deploy cloud infrastructure confidently using the AWS Management Console and AWS CLI.

You’ll learn to:

  • Deploy a virtual machine (EC2)
  • Host a static website (S3)
  • Create and connect a database (RDS)
  • Automate tasks using Lambda
  • Monitor resources using CloudWatch
  • Use IAM roles and permissions securely

🖥️ 1. Launching a Virtual Server Using EC2

Steps:

  1. Go to EC2 Dashboard
  2. Click Launch Instance
  3. Choose an AMI (e.g., Amazon Linux 2023)
  4. Choose t2.micro (Free Tier)
  5. Configure storage (default: 8 GB)
  6. Create a new key pair for SSH
  7. Configure security group to allow SSH (port 22)
  8. Launch the instance

Connect to EC2 via Terminal

bash

 

ssh -i MyKeyPair.pem ec2-user@<Public-IP>

Step

Tool

Notes

Launch EC2

AWS Console

Choose Free Tier AMI

Connect to EC2

Terminal/Putty

SSH key file needed

Install Apache

EC2 CLI

sudo yum install -y httpd


🌐 2. Hosting a Static Website on S3

Create S3 Bucket:

  1. Go to S3
  2. Click Create Bucket
  3. Name the bucket uniquely (e.g., my-website-demo)
  4. Uncheck Block all public access
  5. Enable Static website hosting

Upload Files:

  • Upload your index.html and any assets (CSS/JS)

Set Bucket Policy:

json

 

{

  "Version": "2012-10-17",

  "Statement": [{

    "Sid": "PublicReadGetObject",

    "Effect": "Allow",

    "Principal": "*",

    "Action": "s3:GetObject",

    "Resource": "arn:aws:s3:::my-website-demo/*"

  }]

}

Step

Purpose

Static hosting enabled

Turns S3 into website host

Public access unblocked

Allows file visibility

Bucket policy added

Grants public read permissions


🧮 3. Creating a MySQL Database with RDS

Steps:

  1. Go to RDS → Create database
  2. Choose MySQL, free tier eligible
  3. DB instance class: db.t2.micro
  4. Set master username/password
  5. Enable public access for testing
  6. Set backup retention and enable auto minor version upgrade

Connect to RDS:

Install a MySQL client and run:

bash

 

mysql -h your-db-endpoint.rds.amazonaws.com \

  -u admin -p

Create a table:

sql

 

CREATE DATABASE demo;

USE demo;

CREATE TABLE users (

  id INT AUTO_INCREMENT PRIMARY KEY,

  name VARCHAR(255)

);

Feature

Value

DB Engine

MySQL

Free Tier Instance

db.t2.micro

Storage

20 GB

Backup

7-day default


4. Deploying a Simple Lambda Function

Create a Lambda Function:

  1. Go to Lambda → Create Function
  2. Name: HelloLambda
  3. Runtime: Python 3.10
  4. Create new role with basic permissions

Paste the code:

python

 

def lambda_handler(event, context):

    return {

        'statusCode': 200,

        'body': 'Hello from Lambda!'

    }

Test the Function:

  • Create a test event (leave as default JSON)
  • Click Test
  • View the logs in the output window

Component

Value

Runtime

Python 3.10

Trigger

Manual (Test event)

Output

200 + Hello message


🔐 5. Creating IAM Users and Roles

Create a User:

  1. Go to IAM → Users → Add User
  2. Username: developer
  3. Access type: Programmatic + Console access
  4. Assign permissions:
    • Use Attach existing policies
    • Select AmazonS3FullAccess (for demo)
  5. Create user and download access keys

Create Role:

  1. Go to Roles → Create Role
  2. Choose AWS Service (e.g., Lambda)
  3. Attach AmazonS3ReadOnlyAccess
  4. Name: lambda-s3-read

Feature

Value

IAM User

Developer

IAM Role

Lambda-S3-Read

Policies

AmazonS3FullAccess / ReadOnly


📈 6. Monitoring with CloudWatch

Set Up a CloudWatch Alarm:

  1. Go to CloudWatch → Alarms → Create Alarm
  2. Metric: EC2 → CPU Utilization
  3. Threshold: > 80% for 5 minutes
  4. Notification: SNS or Email

View Lambda Logs:

  1. Go to CloudWatch → Log groups
  2. Select the function HelloLambda
  3. View output, errors, and execution time

Component

Use Case

Alarm

Auto-restart EC2 instance alert

Logs

Debug Lambda functions

Metrics

Monitor RDS/EC2/Lambda usage


📋 Summary Table – First-Time Deployments

Service

Action

Outcome

EC2

Launch virtual machine

Web server, SSH access

S3

Host static site

Public site with HTML/CSS

RDS

Launch MySQL database

Cloud-managed SQL database

Lambda

Create serverless function

Event-based code execution

IAM

Secure user/role access

Permission-based access control

CloudWatch

Monitor and log activity

Alerts, dashboards, log storage


🏁 Final Thoughts

You’ve just completed your first hands-on experience with AWS. From launching servers and databases to running serverless code and monitoring resources, you've touched nearly every part of a scalable application architecture.


Next, you can connect these services into a full-stack app or automate them with AWS CloudFormation or CDK.

Back

FAQs


❓1. What is AWS and what does it do?

Answer:
AWS (Amazon Web Services) is a cloud computing platform that provides on-demand access to computing power, storage, databases, networking, machine learning, and more. It allows users to run applications, host websites, and store data without owning physical servers.

❓2. Is AWS free to use?

Answer:
Yes, AWS offers a Free Tier that gives new users limited access to services like EC2, S3, Lambda, and RDS for 12 months. However, exceeding usage limits or using services not covered by the free tier may result in charges.

❓3. What are the most commonly used AWS services for beginners?

Answer:
Popular AWS services for beginners include:

  • EC2 (virtual servers)
  • S3 (file storage)
  • RDS (databases)
  • Lambda (serverless computing)
  • IAM (user and access management)

❓4. How do I start using AWS as a beginner?

Answer:

  1. Create a free AWS account
  2. Log into the AWS Management Console
  3. Explore core services like EC2 and S3
  4. Follow official tutorials or beginner courses
  5. Practice with small projects to build hands-on experience

❓5. What is EC2 in AWS?

Answer:
EC2 (Elastic Compute Cloud) allows you to run virtual machines (instances) in the cloud. You can choose an operating system, configure storage, and scale resources based on your needs.

❓6. What is S3 used for?

Answer:
Amazon S3 (Simple Storage Service) is used to store and retrieve any amount of data at any time. It is ideal for backups, file hosting, media libraries, and serving static content.

❓7. Do I need to know programming to learn AWS?

Answer:
Not necessarily. While programming helps in using services like Lambda and automation via SDKs or the AWS CLI, many services can be managed through the AWS web console with little to no code.

❓8. Is AWS certification necessary?

Answer:
No, but it’s helpful. Certifications like AWS Cloud Practitioner or Solutions Architect Associate validate your skills and improve job prospects, especially if you plan to work in cloud roles.

❓9. Can I use AWS for hosting a website?

Answer:
Yes. You can host a static website using S3 and CloudFront or a dynamic website using EC2, RDS, and Load Balancer. AWS offers flexible solutions for all types of web hosting.

❓10. What are Availability Zones and Regions in AWS?

Answer:
Regions are geographical locations (like us-east-1, ap-south-1) where AWS operates data centers. Each region contains Availability Zones (AZs)—isolated locations for high availability and fault tolerance.