مقدمة إلى AWS SAM
اكتشف فوائد AWS SAM في تعريف الموارد عديمة الخوادم وتبسيط عمليات النشر مقارنةً باستخدام CloudFormation مباشرةً
مقدمة إلى AWS SAM درس مجاني في Serverless Backend with AWS Lambda & API Gateway على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Serverless Backend with AWS Lambda & API Gateway، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Serverless Backend with AWS Lambda & API Gateway 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Welcome to AWS SAM!
Hello! Today we'll explore AWS SAM, the Serverless Application Model. It's an open-source framework designed to help you build serverless applications on AWS more efficiently.
Think of SAM as a powerful extension to AWS CloudFormation, specifically tailored for serverless resources.
CloudFormation's Verbosity
AWS CloudFormation is a robust service for defining infrastructure as code. However, building serverless applications directly with CloudFormation can be quite verbose.
- A simple AWS Lambda function often requires defining the Lambda resource itself, an IAM role with permissions, and possibly an API Gateway endpoint.
- This can lead to many lines of configuration for even basic setups.
SAM to the Rescue!
AWS SAM aims to simplify this complexity. It provides a shorthand syntax to define common serverless resources.
Instead of defining multiple CloudFormation resources for a single serverless component, SAM lets you define it with just one simplified resource type.
Key Benefits of Using SAM
Using AWS SAM brings several advantages to your serverless development workflow:
- Reduced Boilerplate: Define serverless functions, APIs, and databases with fewer lines of code.
- Local Testing: Test your Lambda functions and API Gateway locally before deploying to AWS.
- Simplified Deployments: The SAM CLI handles packaging, uploading, and deploying your application seamlessly.
- CloudFormation Power: It's built on CloudFormation, so you still get its reliability and features.
SAM Template Basics
Your serverless application's infrastructure is defined in a SAM template, which is typically a YAML or JSON file. The most crucial part that tells CloudFormation to use SAM's simplified syntax is the Transform section.
This Transform line instructs CloudFormation to expand SAM's shorthand into full CloudFormation resources before deployment.
Your First SAM Template
Let's look at a very basic SAM template. This YAML defines a simple 'Hello World' Lambda function. Notice how concise it is compared to what raw CloudFormation would require for the same setup!
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A simple 'Hello World' SAM app.
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
Handler: app.lambda_handler
Runtime: python3.9
CodeUri: ./
MemorySize: 128
Timeout: 30Deconstructing the Template
Let's break down that template:
Transform: AWS::Serverless-2016-10-31: This tells CloudFormation to process the SAM specific syntax.Type: AWS::Serverless::Function: This is a SAM resource type. It automatically creates the Lambda function, an execution IAM role, and necessary permissions.Handler,Runtime,CodeUri: These are standard AWS Lambda properties, specifying where your code is, its language, and the entry point.
SAM CLI - Your Serverless Sidekick
While SAM templates define your resources, the SAM Command Line Interface (CLI) is your primary tool for interacting with your serverless application.
The SAM CLI allows you to:
- Build your application (e.g., package dependencies).
- Test your Lambda functions locally.
- Deploy your application to AWS.
The SAM Workflow (High-Level)
A typical SAM development workflow involves these high-level steps:
- Write your Lambda function code (e.g., Python, Node.js).
- Define your application's resources in a SAM template (YAML/JSON).
- Use
sam buildto prepare your application for deployment. - Use
sam deployto push your application to AWS.
The SAM CLI handles all the underlying CloudFormation magic!
Quick Check on SAM
Based on what we've learned, what is the primary purpose of AWS SAM?
Recap & Next Steps
You've just been introduced to AWS SAM! We learned that SAM simplifies serverless development by providing a concise way to define resources, building on top of CloudFormation.
You also saw a basic SAM template and learned about the powerful SAM CLI.
Next, we'll dive deeper into defining various serverless resources within your SAM templates, including functions, APIs, and databases!
تعلم Serverless Backend with AWS Lambda & API Gateway مع معلم ذكاء اصطناعي — مجانًا
اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.
- الدورات
- 12
- الدروس
- 48
الأسئلة الشائعة
هل درس «مقدمة إلى AWS SAM» مجاني؟
نعم — نص درس «مقدمة إلى AWS SAM» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Serverless Backend with AWS Lambda & API Gateway، انتقل إلى CoddyKit PRO. تتضمن دورة Serverless Backend with AWS Lambda & API Gateway 4 دروس في المجموع.
ماذا ستتعلم في «مقدمة إلى AWS SAM»؟
اكتشف فوائد AWS SAM في تعريف الموارد عديمة الخوادم وتبسيط عمليات النشر مقارنةً باستخدام CloudFormation مباشرةً تتمرن على Serverless Backend with AWS Lambda & API Gateway مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Serverless Backend with AWS Lambda & API Gateway؟
لا تُشترط خبرة سابقة. Serverless Backend with AWS Lambda & API Gateway على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «مقدمة إلى AWS SAM»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Serverless Backend with AWS Lambda & API Gateway هذا؟
نعم. كل درس في Serverless Backend with AWS Lambda & API Gateway يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- مقدمة إلى AWS SAM
- تعريف الموارد عديمة الخوادم
- نشر تطبيقات SAM
- الاختبار وتصحيح الأخطاء محليًا باستخدام SAM CLI