Przejdź do treści
Biblioteka skilli
DevOps i chmura · Budowanie i kod

step-functions

/step-functions

Buduje przepływy AWS Step Functions jako maszyny stanów w Amazon States Language: Lambda i wywołania usług AWS z rozgałęzieniami, krokami równoległymi, ponowieniami, obsługą błędów i zatwierdzeniami przez człowieka.

Repozytorium
skills ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
25.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 25.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Buduje przepływy AWS Step Functions jako maszyny stanów w Amazon States Language: Lambda i wywołania usług AWS z rozgałęzieniami, krokami równoległymi, ponowieniami, obsługą błędów i zatwierdzeniami przez człowieka.

Oryginalny opis (EN)

AWS Step Functions runs serverless workflows defined as state machines in Amazon States Language (ASL): Lambda and direct AWS service calls with branching, parallel and map steps, retries, error catching and human approval callbacks. Use when a user wants to orchestrate Lambda functions, build an AWS workflow or saga, add retries and error handling to a multi-step process, wait for an approval, or write ASL JSON with JSONata.

Jak działa

  1. Overview
  2. Instructions
  3. Examples
  4. Guidelines
Sekcje z nagłówków SKILL.md, w oryginale · 154 linii, 922 słów
Podgląd SKILL.md
---
name: step-functions
description: >-
  AWS Step Functions runs serverless workflows defined as state machines in
  Amazon States Language (ASL): Lambda and direct AWS service calls with
  branching, parallel and map steps, retries, error catching and human
  approval callbacks. Use when a user wants to orchestrate Lambda functions,
  build an AWS workflow or saga, add retries and error handling to a
  multi-step process, wait for an approval, or write ASL JSON with JSONata.
license: Apache-2.0
compatibility: >-
  AWS account with IAM permissions to create state machines and a role Step
  Functions can assume; AWS CLI v2 or SDK for JavaScript v3.
metadata:
  author: terminal-skills
  version: 1.1.0
  category: devops
  tags: "aws, step-functions, workflow, state-machine, serverless"
---

# AWS Step Functions

## Overview

Step Functions executes a state machine written in Amazon States Language (JSON). Each state is a Task (Lambda or any of the many AWS services, called directly), Choice, Parallel, Map, Wait, Pass, Succeed or Fail. Two workflow types exist and the type cannot be changed after creation:

- **Standard**: runs up to one year, exactly-once execution, execution history available. Use for payments, approvals, long processes.
- **Express**: runs up to five minutes, at-least-once, billed by executions and duration, history only in CloudWatch Logs. Use for high-volume, idempotent event processing.

New workflows should set `"QueryLanguage": "JSONata"` at the top level. JSONata replaces the five JSONPath fields (`InputPath`, `Parameters`, `ResultSelector`, `ResultPath`, `OutputPath`) with `Arguments` and `Output`, writes expressions as `"{% ... %}"`, and uses `$states.input` and `$states.result`. Existing JSONPath machines keep working; the older field names below apply only to them.

## Instructions

### Step 1: Write the definition

A JSONata order workflow with a direct Lambda integration, retry, catch and a Choice. Use the optimized `arn:aws:states:::lambda:invoke` resource; its result is under `$states.result.Payload`.

```json
{
  "Comment": "Order processing",
  "QueryLanguage": "JSONata",
  "StartAt": "ValidateOrder",
  "States": {
    "ValidateOrder": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Arguments": {
        "FunctionName": "arn:aws:lambda:eu-west-1:482910563127:function:validate-order:live",
        "Payload": "{% $states.input %}"
      },
      "Assign": { "orderId": "{% $states.input.orderId %}" },
      "Output": "{% $states.result.Payload %}",
      "Retry": [
        {
          "ErrorEquals": ["Lambda.ServiceException", "Lambda.AWSLambdaException", "Lambda.SdkClientException", "Lambda.TooManyRequestsException"],
          "IntervalSeconds": 2,
          "MaxAttempts": 4,
          "BackoffRate": 2,
          "JitterStrategy": "FULL"
        }
      ],
      "Catch": [
        { "ErrorEquals": ["ValidationError"], "Next": "RejectOrder", "Output": "{% $states.errorOutput %}" }
      ],
      "Next": "InventoryDecision"
    },
    "InventoryDecision": {
      "Type": "Choice",
      "Choices": [
        { "Condition": "{% $states.input.inStock = true %}", "Next": "ChargeCard" }
      ],
      "Default": "RejectOrder"
    },
    "ChargeCard": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Arguments": {
        "FunctionName": "arn:aws:lambda:eu-west-1:482910563127:function:charge-card:live",
        "Payload": { "orderId": "{% $orderId %}", "total": "{% $states.input.total %}" }
      },
      "Output": "{% $states.result.Payload %}",
      "End": true
    },
    "RejectOrder": {
      "Type": "Fail",
      "Error": "OrderRejected",
      "Cause": "Validation failed or item out of stock"
    }
  }
}
```

Notes on the definition:

- `Assign` stores values in workflow variables (`$orderId`) that every later state can read. Assignments in one `Assign` block all see the values from before that block.
- Retriers and catchers are evaluated in order; `States.ALL` must be alone in its entry and last. A `Catch` replaces the state's output with the error output unless you set `Output`.
- Error names you can match include `States.TaskFailed`, `States.Timeout`, `States.Runtime`, and Lambda's `Lambda.Unknown` and `Sandbox.Timedout`. Custom error names must not start with `States.`.
- Set `TimeoutSeconds` on every Task; without it a stuck task can wait for up to a year in a Standard workflow.

### Step 2: Direct service integrations and callbacks

Calling DynamoDB, SQS, SNS, EventBridge, ECS and other services directly skips a Lambda hop. Append `.waitForTaskToken` to pause until something calls `SendTaskSuccess` or `SendTaskFailure` with the token:

```jsonc
// excerpt: one entry of the top-level "States" object (Standard workflows only)
"RequestApproval": {
  "Type": "Task",
  "Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
  "Arguments": {
    "QueueUrl": "https://sqs.eu-west-1.amazonaws.com/482910563127/refund-approvals",
    "MessageBody": { "taskToken": "{% $states.context.Task.Token %}", "orderId": "{% $orderId %}" }
  },
  "TimeoutSeconds": 86400,
  "Next": "IssueRefund"
}
```

### Step 3: Map and Parallel

`Map` runs an `ItemProcessor` per array item (the old `Iterator` and `Parameters` fields are deprecated; use `ItemProcessor` and `ItemSelector`). `MaxConcurrency` caps parallel iterations; `0` means no limit. `Parallel` runs fixed `Branches` and returns an array of their outputs.

### Step 4: Deploy, validate and run

```console
$ aws stepfunctions validate-state-machine-definition --definition file://order.asl.json --type STANDARD
$ aws stepfunctions create-state-machine --name order-processing --type STANDARD \
    --definition file://order.asl.json \
    --role-arn arn:aws:iam::482910563127:role/order-sfn-role
$ aws stepfunctions start-execution \
    --state-machine-arn arn:aws:states:eu-west-1:482910563127:stateMachine:order-processing \
    --name order-A-1042 --input '{"orderId":"A-1042","total":59.9}'
$ aws stepfunctions describe-execution --execution-arn arn:aws:states:eu-west-1:482910563127:execution:order-processing:order-A-1042
```

`validate-state-machine-definition` checks ASL without creating anything and is good for CI. `test-state` runs a single state in isolation. Express workflows can be called synchronously with `start-sync-execution`.

From Node, install `@aws-sdk/client-sfn` (SDK v3):

```typescript
import { SFNClient, StartExecutionCommand } from '@aws-sdk/client-sfn'

const sfn = new SFNClient({ region: 'eu-west-1' })
const out = await sfn.send(new StartExecutionCommand({
  stateMachineArn: process.env.ORDER_STATE_MACHINE_ARN!,
  name: 'order-A-1042', // reusing a name with different input is rejected
  input: JSON.stringify({ orderId: 'A-1042', total: 59.9 }),
}))
console.log(out.executionArn)
```

## Examples

### Example 1: Add retries to a flaky Lambda step

User: "My payment step fails now and then with Lambda throttling. Make the workflow retry."

Add the `Retry` block from Step 1 to the `ChargeCard` state with `Lambda.TooManyRequestsException` and `Lambda.ServiceException` in `ErrorEquals`, `JitterStrategy: "FULL"`, and `MaxAttempts: 4`. Because charging is not idempotent, pass `$orderId` as an idempotency key in `Payload`. Re-run `validate-state-machine-definition`; expect `"result": "OK"`.

### Example 2: Approve before refunding

User: "Pause the refund until a manager approves it."

Use the `RequestApproval` state from Step 2. The worker that reads the SQS queue calls `aws stepfunctions send-task-success --task-token "$TOKEN" --task-output '{"approved":true}'` (or `send-task-failure`). The execution waits in that state until then or until `TimeoutSeconds` expires, and the timeout is a `States.Timeout` error you can catch.

## Guidelines

- Pick the workflow type deliberately: it is immutable. Express is at-least-once, so its tasks must be idempotent.
- Input and output of any task or state are limited to 256 KiB; pass references (S3 keys) for big data, not the data.
- Handle Lambda service exceptions in every Lambda Task, as the AWS best-practices page advises.
- Give the execution role least privilege: only the Lambda ARNs and service actions the machine calls, plus `lambda:InvokeFunction` on the exact functions.
- Do not put secrets in state input; history and CloudWatch Logs record it. Read secrets inside the task.
- When a Standard run fails midway, `aws stepfunctions redrive-execution` restarts it from the failed state within 14 days of completion (not available for Express).
Pliki w paczce (2)
  • SKILL.md 8 KB
  • _scores.json 1 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · TerminalSkills/skills100Apache-2.0
itsmostafa/aws-agent-skills100MIT
aws-samples/sample-claude-code-plugins-for-startups100MIT

Migawka bazy z 13.11.2026 · wersja paczki 4c9af63c2bcc (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100aws-step-functions
    Pisze i edytuje maszyny stanów AWS Step Functions w Amazon States Language z JSONata: typy stanów, Retry i Catch, integracje usług, Distributed Map, wzorce saga i przepływy Standard oraz Express.
  • 95cloud-native-serverless-orchestration
    Projektuje maszyny stanów AWS Step Functions z poprawnym ASL, obsługą błędów Retry i Catch oraz wyborem Standard lub Express.
  • 100aws-lambda-durable-functions
    Buduje odporne, długotrwałe, wieloetapowe aplikacje na AWS Lambda durable functions z trwałym stanem, ponowieniami i orkiestracją: model replay, kroki, wait i callback, saga oraz LocalDurableTestRunner.
  • 100aws-lambda-durable-functions
    Buduje odporne, długotrwałe, wieloetapowe aplikacje na AWS Lambda durable functions z trwałym stanem, ponowieniami i orkiestracją: model replay, kroki, wait i callback, saga oraz LocalDurableTestRunner.
  • 95aws-lambda-durable-functions
    Buduje długo działające, wieloetapowe aplikacje w AWS Lambda durable functions: trwały stan, ponowienia, czekanie, callbacki i wzorzec saga.
  • 90aws-lambda
    Projektuje, buduje, wdraża, testuje i debuguje aplikacje serverless na AWS Lambda z API Gateway, EventBridge i Step Functions.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.