Serverless Backend with AWS Lambda & API Gateway · 강의

상태 머신 구축

다양한 사용 사례에 맞는 여러 상태 머신 유형(Standard, Express)을 설계하고 구현하며 Lambda 및 기타 서비스와 통합합니다.

레슨 2/411개 단계

상태 머신 구축은(는) CoddyKit의 무료 Serverless Backend with AWS Lambda & API Gateway 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Serverless Backend with AWS Lambda & API Gateway 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Serverless Backend with AWS Lambda & API Gateway 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Build Your First Workflow

Welcome back! In the previous lesson, we learned what AWS Step Functions are. Now, let's dive into building them!

You'll learn how to define different steps (states) and connect them to create powerful, automated workflows. We'll also explore the two main types of workflows: Standard and Express.

Anatomy of a State Machine

A Step Functions state machine is a workflow that defines a series of steps, called states. Each state performs a specific task or makes a decision.

  • States: The individual steps in your workflow.
  • Transitions: Rules that determine which state comes next.
  • Input/Output: Data passed between states.

Think of it like a flowchart, but executed by AWS!

Common State Types

Step Functions offers various state types to build your logic:

  • Task: Performs work by calling a service (e.g., Lambda, ECS).
  • Pass: Passes its input to its output without performing work. Useful for debugging or structuring.
  • Choice: Adds branching logic (if/else).
  • Wait: Pauses the execution for a specified time or until a specific time.
  • Succeed/Fail: Stops the execution successfully or with an error.
  • Parallel: Executes multiple branches in parallel.

Defining a Simple Pass State

Let's start with a simple Pass state. This state simply takes its input and passes it as output. It's often used for testing or structuring your state machine.

State machines are defined using Amazon States Language (ASL), which is a JSON-based structure.

Pass State ASL Example

Here's how a Pass state looks in ASL. It defines the state name, its type, and where to go next.

{ "Comment": "A simple Pass state machine",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Pass",
      "Result": {
        "message": "Hello from Step Functions!"
      },
      "End": true
    }
  }
}

Standard Workflows: The Durable Choice

AWS Step Functions offers two workflow types: Standard and Express.

Standard Workflows are ideal for long-running, durable, and auditable workflows. They can run for up to a year!

  • Durability: Retains full execution history for up to 90 days.
  • Auditability: Easy to track every step and input/output.
  • Use Cases: Order fulfillment, data processing pipelines, human approvals.

Express Workflows: Speed and Scale

Express Workflows are designed for high-volume, event-driven workloads. They are much faster and more cost-effective for short-duration tasks.

  • Speed: Can complete thousands of executions per second.
  • Cost: Priced per execution and duration, often cheaper for short tasks.
  • History: Execution history is limited (up to 90 days in CloudWatch Logs, not directly in Step Functions console).
  • Use Cases: Microservice orchestration, real-time streaming data processing, mobile backend processing.

Integrating Lambda: The Task State

One of the most common ways to perform work in a state machine is using a Task state to invoke an AWS Lambda function.

The Resource field in the ASL specifies the ARN of the Lambda function to call.

Example Lambda for Step Functions

This simple Python Lambda function receives an event (input from Step Functions) and returns a modified message. Step Functions will pass its output to the next state.

import json

def lambda_handler(event, context):
    print(f"Received event: {json.dumps(event)}")
    name = event.get('name', 'World')
    return {
        'statusCode': 200,
        'body': f"Hello, {name}! This is from Lambda."
    }

Workflow Type Challenge

You need to build a workflow for processing thousands of incoming IoT sensor readings every minute. Each reading takes less than 1 second to process.

Recap: Building Workflows

Great job! You've learned the fundamentals of building AWS Step Functions state machines:

  • State machines are defined by a series of states and transitions.
  • Key state types include Task, Pass, Choice, and Wait.
  • Standard Workflows are for long-running, auditable processes.
  • Express Workflows are for high-volume, short-duration tasks.
  • You can integrate Lambda functions using a Task state.

Next, we'll explore orchestrating complex workflows!

무료로 시작

AI 튜터와 함께 Serverless Backend with AWS Lambda & API Gateway을(를) 배우세요 — 무료

브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.

코스
12
레슨
48

자주 묻는 질문

“상태 머신 구축” 강의는 무료인가요?

네 — “상태 머신 구축” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Serverless Backend with AWS Lambda & API Gateway 강의 전체를 잠금 해제할 수 있습니다. Serverless Backend with AWS Lambda & API Gateway 강의에는 총 4개의 강의가 포함되어 있습니다.

“상태 머신 구축”에서 뭘 배우나요?

다양한 사용 사례에 맞는 여러 상태 머신 유형(Standard, Express)을 설계하고 구현하며 Lambda 및 기타 서비스와 통합합니다. 브라우저에서 직접 실행하는 실습 코드로 Serverless Backend with AWS Lambda & API Gateway을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Serverless Backend with AWS Lambda & API Gateway을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Serverless Backend with AWS Lambda & API Gateway은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“상태 머신 구축” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Serverless Backend with AWS Lambda & API Gateway 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Serverless Backend with AWS Lambda & API Gateway 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. AWS Step Functions 소개
  2. 상태 머신 구축
  3. 복잡한 워크플로 오케스트레이션
  4. 상태 머신의 오류 처리 및 재시도
← Serverless Backend with AWS Lambda & API Gateway(으)로 돌아가기