Exposing APIs and Coordinating Workflows with API Gateway and Step Functions
This lesson explains how applications made of pieces that call each other use Amazon API Gateway to expose those pieces as APIs and AWS Step Functions to coordinate them into multi-step workflows.
Learning outcomes
After completing this lesson, you will be able to:
- Describe what Amazon API Gateway provides.
- Describe how AWS Step Functions coordinates the steps of a business process.
- Distinguish messaging services from workflow services.
Building APIs
An API lets applications, such as a mobile app, use back-end systems without knowing how they work. Amazon API Gateway creates, publishes and secures REST, HTTP and WebSocket APIs at any scale; for example, a mobile app calls an API that runs Lambda functions. API Gateway handles the work that every API needs: authorising callers, throttling requests so the back end is not overwhelmed, caching responses and monitoring usage. The following table summarises the service.
| Service | What it does | Example |
|---|---|---|
| Amazon API Gateway | Creates, publishes and secures REST, HTTP and WebSocket APIs at any scale | A mobile app calls an API that triggers Lambda functions |
API Gateway
Coordinating steps
Many business processes have several steps that must happen in order, such as checking an order, charging the customer, reserving stock and sending a confirmation. AWS Step Functions runs such processes as workflows, defined visually as a series of steps called a state machine. It provides built-in retries, error handling, waits for human approval and parallel branches, so this logic does not have to be written into each component. Each step can call AWS Lambda or one of hundreds of AWS services directly.
Messaging versus workflows
AWS provides several services for connecting application components through messages, events and workflows. They differ as follows.
- Amazon SQS queues messages so components can work at their own pace.
- Amazon SNS sends one message to many subscribers (fan-out), including email and SMS.
- Amazon EventBridge routes events from AWS services, SaaS apps and your own apps to targets by rules, and schedules tasks.
- Step Functions coordinates a sequence of steps with state, which messaging alone does not track.
Messaging or workflow?
An order process must check stock, take payment, wait for a warehouse to confirm shipment and then send an email, retrying failed steps automatically. Which service coordinates these steps?
AWS Step Functions. SQS and SNS move messages between components but do not track the progress of a multi-step process or handle retries per step.
What does AWS Step Functions do?
Show answer
It coordinates several steps, such as Lambda functions and service calls, into a visual workflow with retries and error handling.
Exam Tips
Remember for the exam
- API Gateway creates and secures REST, HTTP and WebSocket APIs.
- API Gateway can throttle and cache requests to protect the back end.
- Step Functions coordinates multi-step workflows with retries and error handling.
- SQS decouples with queues; SNS fans out; EventBridge routes events.