Để bắt đầu xây dựng các ứng dụng dựa trên SAM, trước tiên chúng ta phải cài đặt SAM CLI, thiết lập thông tin xác thực AWS và khởi tạo một ứng dụng SAM đơn giản.
Bạn có thể tham khảo: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html
Nếu bạn đã thiết lập thông tin xác thực AWS từ các bài viết trước, bạn có thể bỏ qua bước này.
Mở IAM console.
Nhấp vào Users trên menu bên trái.
Nhấp vào nút Create user.

Tại trang Step 1: Specify user details:
sam-admin.
Tại trang Step 2: Set permissions:

Tại trang Step 3: Review and create:

Tại trang Step 4: Retrieve password:

Tại trang sam-admin:

Cuộn xuống phần Access keys:

Tại Step 1: Access key best practices & alternatives:

Tại Step 2: Set description tag:

Tại Step 3: Retrieve access keys:

Chạy lệnh sau bằng terminal trên thiết bị của bạn:
aws configure
ap-southeast-1).json hoặc bỏ qua.
Chạy lệnh dưới đây tại thư mục nơi bạn muốn triển khai ứng dụng:
sam init
Chọn các tùy chọn sau:
Which template source would you like to use?
1 - AWS Quick Start Templates
2 - Custom Template Location
Choice: 1
Choose an AWS Quick Start application template
1 - Hello World Example
2 - Data processing
3 - Hello World Example with Powertools for AWS Lambda
4 - Multi-step workflow
5 - Scheduled task
6 - Standalone function
7 - Serverless API
8 - Infrastructure event management
9 - Lambda Response Streaming
10 - GraphQLApi Hello World Example
11 - Full Stack
12 - Lambda EFS example
13 - Serverless Connector Hello World Example
14 - Multi-step workflow with Connectors
15 - DynamoDB Example
16 - Machine Learning
Template: 1
Use the most popular runtime and package type? (python3.13 and zip) [y/N]: y
Would you like to enable X-Ray tracing on the function(s) in your application? [y/N]: N
Would you like to enable monitoring using CloudWatch Application Insights? [y/N]: N
Would you like to set Structured Logging in JSON format on your Lambda functions? [y/N]: N
Project name [sam-app]: fcaj-book-shop

Bạn đã tạo thành công một dự án SAM mẫu. Tiếp theo, chúng ta sẽ chỉnh sửa dự án đó theo kiến trúc ứng dụng của chúng ta.