Skip to content
Star
488
Star
488

Simple ETL (AWS Emulator)

This guide shows you how to build a file processing pipeline using AWS S3, Lambda, and DynamoDB locally with AWS Emulator, the official local emulator from AWS, and Python. This lab demonstrates how S3 uploads trigger a Lambda to log metadata into a DynamoDB table.

Run every script through mise: mise run <task> loads .env, removes any real AWS credentials from the environment and puts the lab tools on the PATH.

  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

    It builds the AWS Emulator image, installs the tools and deploys the pipeline with Boto3.

  2. Run the Example:

    Terminal window
    mise run main
  1. main.py:

    • Open: Open main.py.
    • Breakpoints: Set breakpoints in the code.
    • Run: Press F5 to start debugging.
  2. Tests:

    • Open: Open tests/test_file_pipeline.py.
    • Breakpoints: Set breakpoints in the test code.
    • Run: Use the VS Code Testing tab and click the Debug Test icon next to the test.

The tests deploy their own pipeline (names in .env.test) and remove it afterwards.

  • Individually: Run tests individually from the VS Code Testing tab.
  • All tests: Run the automated script:
    Terminal window
    mise run test

The setup deploys the pipeline with Boto3. Before deploying with another method, run mise run destroy:boto3 to avoid resource name conflicts, and when switching between the other methods, run Clean Up for the current one first.

Terminal window
mise run deploy:terraform
  • Verify that the AWS CLI reaches the emulator (account 000000000000):
    Terminal window
    mise exec -- aws sts get-caller-identity
  • Check S3 Bucket:
    Terminal window
    mise exec -- aws s3 ls s3://file-uploads-bucket
  • Scan DynamoDB Table:
    Terminal window
    mise exec -- aws dynamodb scan --table-name file-logs
  • View Lambda Logs:
    Terminal window
    mise exec -- aws logs tail /aws/lambda/s3-file-processor

To remove only the deployed resources, run the destroy script of the method you used:

Terminal window
mise run destroy:terraform

To remove everything, stop the emulator (it keeps all resources in memory) and delete its image:

Terminal window
docker compose down --rmi local
IssueSolution
Could not connect to the endpoint URL or SSL errorsRun AWS CLI commands with mise exec -- aws ... from the lab root, so they load .env, and check that the emulator is healthy with docker compose ps.
AccessDenied: Sign the request with the emulator credentialsReal AWS credentials in your environment take precedence. Run commands with mise run or mise exec, which remove them.
Resources are goneAWS Emulator keeps resources in memory, so a restart deletes them. Deploy again. For Terraform, delete deploy/terraform/terraform.tfstate first.
Lambda not triggeringCheck the logs with mise exec -- aws logs tail /aws/lambda/s3-file-processor.
AWS Toolkit cannot connect after a restartThe emulator creates a new certificate on each start. Run Developer: Reload Window in VS Code.