Back to DevOps

AWS Cloud Fundamentals

Master AWS cloud fundamentals with our comprehensive tutorial. Learn EC2, S3, RDS, Lambda, and infrastructure management through practical examples.

Services Explained

Taste of Devops

Introduction to Cloud Computing

Cloud computing provides on-demand access to computing resources over the internet. AWS (Amazon Web Services) is the world's most comprehensive and broadly adopted cloud platform, offering over 200 services.

Examples:

# Cloud Service Models
IaaS - Infrastructure as a Service (EC2, VPC)
PaaS - Platform as a Service (Elastic Beanstalk)
SaaS - Software as a Service (Gmail, Salesforce)

# Cloud Deployment Models
Public Cloud - AWS, Azure, GCP
Private Cloud - On-premises
Hybrid Cloud - Combination of both

Understanding cloud computing fundamentals

AWS CLI Basics

The AWS Command Line Interface (CLI) is a unified tool to manage AWS services. With just one tool, you can control multiple AWS services from the command line.

Examples:

# Install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Install AWS CLI on Linux

# Configure AWS CLI
aws configure
# Enter: Access Key ID
# Enter: Secret Access Key
# Enter: Default region (e.g., us-east-1)
# Enter: Default output format (json)

Configure AWS credentials and default settings

# Verify configuration
aws sts get-caller-identity

Check your AWS identity and credentials

Amazon EC2 (Elastic Compute Cloud)

EC2 provides scalable computing capacity in the cloud. You can launch virtual servers, configure security and networking, and manage storage.

Examples:

# List EC2 instances
aws ec2 describe-instances

View all EC2 instances in your account

# Launch an EC2 instance
aws ec2 run-instances \
  --image-id ami-0c55b159cbfafe1f0 \
  --instance-type t2.micro \
  --key-name MyKeyPair \
  --security-group-ids sg-0123456789abcdef0 \
  --subnet-id subnet-0123456789abcdef0

Launch a new EC2 instance --image-id: AMI ID --instance-type: Instance size --key-name: SSH key pair

# Stop an instance
aws ec2 stop-instances --instance-ids i-1234567890abcdef0

# Start an instance
aws ec2 start-instances --instance-ids i-1234567890abcdef0

# Terminate an instance
aws ec2 terminate-instances --instance-ids i-1234567890abcdef0

Manage EC2 instance lifecycle

Amazon S3 (Simple Storage Service)

S3 is object storage built to store and retrieve any amount of data from anywhere. It's designed for 99.999999999% durability.

Examples:

# Create an S3 bucket
aws s3 mb s3://my-unique-bucket-name

Create a new S3 bucket (name must be globally unique)

# List all buckets
aws s3 ls

# List contents of a bucket
aws s3 ls s3://my-bucket-name

List S3 buckets and their contents

# Upload a file
aws s3 cp myfile.txt s3://my-bucket-name/

# Download a file
aws s3 cp s3://my-bucket-name/myfile.txt ./

# Sync a directory
aws s3 sync ./local-folder s3://my-bucket-name/remote-folder

Upload, download, and sync files with S3

# Delete a file
aws s3 rm s3://my-bucket-name/myfile.txt

# Delete a bucket (must be empty)
aws s3 rb s3://my-bucket-name

Remove files and buckets

AWS IAM (Identity and Access Management)

IAM enables you to manage access to AWS services and resources securely. You can create and manage AWS users and groups, and use permissions to allow and deny access.

Examples:

# List IAM users
aws iam list-users

# Create a new user
aws iam create-user --user-name john-doe

Manage IAM users

# Create an access key for a user
aws iam create-access-key --user-name john-doe

Generate access keys for programmatic access

# Attach a policy to a user
aws iam attach-user-policy \
  --user-name john-doe \
  --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess

Grant permissions using managed policies

Amazon RDS (Relational Database Service)

RDS makes it easy to set up, operate, and scale a relational database in the cloud. It supports MySQL, PostgreSQL, Oracle, SQL Server, and more.

Examples:

# List RDS instances
aws rds describe-db-instances

View all RDS database instances

# Create a MySQL database
aws rds create-db-instance \
  --db-instance-identifier mydb \
  --db-instance-class db.t3.micro \
  --engine mysql \
  --master-username admin \
  --master-user-password MyPassword123 \
  --allocated-storage 20

Create a new RDS MySQL database --db-instance-class: Instance size --allocated-storage: Storage in GB

# Create a database snapshot
aws rds create-db-snapshot \
  --db-instance-identifier mydb \
  --db-snapshot-identifier mydb-snapshot-2024

Create a backup snapshot of your database

AWS Lambda (Serverless Computing)

Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume.

Examples:

# List Lambda functions
aws lambda list-functions

View all Lambda functions in your account

# Create a Lambda function
aws lambda create-function \
  --function-name my-function \
  --runtime nodejs18.x \
  --role arn:aws:iam::123456789012:role/lambda-role \
  --handler index.handler \
  --zip-file fileb://function.zip

Create a new Lambda function --runtime: Programming language --handler: Entry point

# Invoke a Lambda function
aws lambda invoke \
  --function-name my-function \
  --payload '{"key":"value"}' \
  response.json

Execute a Lambda function and get response

AWS CloudFormation (Infrastructure as Code)

CloudFormation provides a common language to describe and provision all infrastructure resources in your cloud environment using templates.

Examples:

# Create a stack from a template
aws cloudformation create-stack \
  --stack-name my-stack \
  --template-body file://template.yaml \
  --parameters ParameterKey=KeyName,ParameterValue=MyKey

Deploy infrastructure using CloudFormation template

# List all stacks
aws cloudformation list-stacks

# Describe a stack
aws cloudformation describe-stacks --stack-name my-stack

View CloudFormation stacks and their status

# Update a stack
aws cloudformation update-stack \
  --stack-name my-stack \
  --template-body file://updated-template.yaml

# Delete a stack
aws cloudformation delete-stack --stack-name my-stack

Update or delete CloudFormation stacks

Quick Reference

Core Services

  • • EC2 - Virtual servers
  • • S3 - Object storage
  • • RDS - Managed databases
  • • Lambda - Serverless compute

Best Practices

  • ✓ Use IAM roles, not root
  • ✓ Enable MFA authentication
  • ✓ Tag all resources
  • ✓ Monitor with CloudWatch