Skip to content
Star
478
Star
478

Step Functions (LocalStack)

This guide shows you how to work with AWS Step Functions locally using LocalStack, Python, and VS Code AWS Toolkit. This lab demonstrates a user onboarding workflow with parallel Lambda execution and IAM user creation.

  1. Setup Environment:

    Open VS Code in the project folder and execute this command in the Command Palette:

    Terminal window
    > Dev Containers: Reopen in Container
  2. Configure LocalStack Profile: Set up a dedicated AWS profile for LocalStack:

    Terminal window
    aws configure set aws_access_key_id test --profile localstack
    aws configure set aws_secret_access_key test --profile localstack
    aws configure set region us-east-1 --profile localstack
    aws configure set output json --profile localstack
    aws configure set endpoint_url http://localhost:4566 --profile localstack
  3. Run the Example:

    • Start LocalStack:
      Terminal window
      docker compose up -d
    • Deploy infrastructure:
      Terminal window
      python deploy.py
    • Run the workflow:
      Terminal window
      python main.py
  1. Open Command Palette: Press F1 or Ctrl+Shift+P.
  2. Connect to AWS: Type and select AWS: Connect to AWS.
  3. Select Profile: Select the localstack profile.
  4. Render Graph: Open step_function.asl.json and click the Visual Graph icon (top-right).
  5. Execute: In the AWS Explorer, right-click UserOnboardingWorkflow and select Start Execution.
  1. Verify IAM User Creation:
    Terminal window
    aws iam list-users --profile localstack
  2. Verify DynamoDB Logs:
    Terminal window
    aws dynamodb scan --table-name UserLogs --profile localstack
  3. Verify Lambda Functions:
    Terminal window
    aws lambda list-functions --profile localstack
Terminal window
docker compose down -v
IssueSolution
Lambda function is ‘Pending’Wait 5-10 seconds after deploy.py and try again. LocalStack may still be initializing the Lambda environment.
Connection refusedEnsure LocalStack is running: docker ps