Skip to content

Add Step Functions state machine for async processing; various fixes in setup#6

Merged
whummer merged 27 commits intomainfrom
fix/ui-api-endpoint
Apr 18, 2026
Merged

Add Step Functions state machine for async processing; various fixes in setup#6
whummer merged 27 commits intomainfrom
fix/ui-api-endpoint

Conversation

@whummer
Copy link
Copy Markdown
Member

@whummer whummer commented Apr 18, 2026

  • add Step Functions state machine for async processing
  • enhance workshop demo application logic
  • various fixes in setup

whummer and others added 10 commits April 18, 2026 16:29
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tches boto3

Setting localhost:4566 inside Lambda containers breaks service calls since
localhost resolves to the container itself, not LocalStack. Removing the
override lets LocalStack inject the correct endpoint automatically.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…laced

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DynamoDB returns numeric fields as Decimal; use a custom JSONEncoder
to convert them to int before serializing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- order_processor now starts a Step Functions execution when triggered
  by SQS, and handles individual steps (validate, process_payment,
  fulfill, handle_failure) when invoked by the state machine
- State machine: ValidateOrder → wait 3s → ProcessPayment → wait 3s →
  FulfillOrder, with HandleFailure catch on all steps
- DDB status transitions: pending → validating → payment_processing →
  fulfilled (or failed)
- order_handler: add created_at timestamp to each order
- UI: add Created column, pipeline progress indicator per order, updated
  status badges for all new states; sort orders newest-first
- main.tf: remove redundant endpoints{} block (tflocal handles this),
  add SFN state machine + IAM role, STATE_MACHINE_ARN env var

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
aws_lambda_function.order_processor and aws_sfn_state_machine.order_processing
mutually reference each other. Break the cycle by constructing the ARN from
aws_caller_identity + aws_region data sources instead of the resource itself.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…h auto-refresh

- order_processor: add sleep() calls per step to simulate processing time
- order_processor: write step timestamps (validating_at, payment_at, etc.) to DDB
- index.html: expandable rows showing full order ID and step timestamps
- index.html: auto-refresh (3s) only while orders are in non-terminal status

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@whummer whummer force-pushed the fix/ui-api-endpoint branch from 9c5d4c9 to 21fc142 Compare April 18, 2026 14:34
Default 3s timeout was too short for steps with sleep() calls.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@whummer whummer force-pushed the fix/ui-api-endpoint branch from 54ce591 to 62ff150 Compare April 18, 2026 14:47
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@whummer whummer force-pushed the fix/ui-api-endpoint branch from 62ff150 to b32820f Compare April 18, 2026 14:48
whummer and others added 15 commits April 18, 2026 16:51
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- replay_dlq.py: handle empty stdout from receive-message (empty DLQ)
- index.html: poll /_localstack/chaos/faults every 5s, show warning
  banner with active fault details when chaos mode is enabled

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Appending a short random suffix allows retried orders to start a fresh
execution without hitting ExecutionAlreadyExists.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without this, the SQS consumer Lambda always succeeded (SFN is async),
so DDB throttle errors never caused SQS retries or DLQ delivery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- order_handler: add POST /orders/replay endpoint to drain DLQ
- terraform: add ORDERS_DLQ_URL env var and /orders/replay API GW route
- index.html: checkbox to poll /replay every 5s, flashes count on replay
- index.html: detail rows now show step description alongside timestamp

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Left nav: Orders / About sections
- Right sidebar: chaos mode toggle, DLQ auto-resume, API endpoint
- About section: architecture diagram, service breakdown, chaos walkthrough
- Chaos mode toggle directly calls LocalStack chaos API from the browser

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
depends_on alone doesn't redeploy the stage when new resources are added.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…+ dropdown

- terraform: products table with 6 pre-seeded LocalStack swag items
- order_handler: GET /products endpoint
- index.html: Products nav section with table; order form uses product dropdown
- index.html: fulfilled orders show S3 receipt download link in detail row

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@whummer whummer merged commit 103ec17 into main Apr 18, 2026
1 check passed
@whummer whummer deleted the fix/ui-api-endpoint branch April 18, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant