📖 AWS Cloud Practitioner - AWS Core Services
70 phút

AWS Core Services

Giới thiệu AWS

Amazon Web Services (AWS) là nền tảng cloud computing hàng đầu.

Compute Services

EC2 (Elastic Compute Cloud)

# Launch EC2 instance via AWS CLI
aws ec2 run-instances \
    --image-id ami-0c02fb55956c7d316 \
    --count 1 \
    --instance-type t2.micro \
    --key-name my-key-pair \
    --security-group-ids sg-903004f8 \
    --subnet-id subnet-6e7f829e

Lambda (Serverless)

// Lambda function handler
exports.handler = async (event) => {
  console.log('Event:', JSON.stringify(event, null, 2));
  
  const response = {
    statusCode: 200,
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      message: 'Hello from Lambda!',
      input: event,
    }),
  };
  
  return response;
};

Storage Services

S3 (Simple Storage Service)

import boto3

# Create S3 client
s3 = boto3.client('s3')

# Upload file
s3.upload_file('local-file.txt', 'my-bucket', 'remote-file.txt')

# Download file
s3.download_file('my-bucket', 'remote-file.txt', 'local-file.txt')

# List objects
response = s3.list_objects_v2(Bucket='my-bucket')
for obj in response.get('Contents', []):
    print(f"Key: {obj['Key']}, Size: {obj['Size']}")

EBS (Elastic Block Store)

  • Persistent block storage for EC2
  • Multiple volume types (gp3, io1, st1)
  • Snapshots for backup

Database Services

RDS (Relational Database Service)

# Create RDS instance
aws rds create-db-instance \
    --db-instance-identifier my-db \
    --db-instance-class db.t3.micro \
    --engine mysql \
    --master-username admin \
    --master-user-password password123 \
    --allocated-storage 20

DynamoDB (NoSQL)

// DynamoDB document client
const { DynamoDBClient } = require("@aws-sdk/client-dynamodb");
const { DynamoDBDocumentClient, PutCommand } = require("@aws-sdk/lib-dynamodb");

const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);

// Put item
await docClient.send(new PutCommand({
  TableName: "Users",
  Item: {
    UserId: "123",
    Name: "John Doe",
    Email: "john@example.com",
    CreatedAt: new Date().toISOString()
  }
}));

Networking & Content Delivery

VPC (Virtual Private Cloud)

# CloudFormation VPC template
Resources:
  MyVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16
      EnableDnsHostnames: true
      Tags:
        - Key: Name
          Value: MyVPC

CloudFront (CDN)

  • Global content delivery network
  • Low latency
  • DDoS protection

IAM (Identity and Access Management)

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject"
      ],
      "Resource": "arn:aws:s3:::my-bucket/*"
    }
  ]
}

Bài tập thực hành

Hãy tạo architecture diagram cho ứng dụng web trên AWS!

📝 Bài tập (2)

  1. Thiết kế kiến trúc ứng dụng web trên AWS

  2. Thực hành tạo S3 bucket và upload files sử dụng AWS CLI

Tiến độ khóa học
Bài học "AWS Core Services" - Khóa học "AWS Cloud Practitioner"