Skip to content
Star
478
Star
478

Storage Writer

This guide shows you how to build an AWS Lambda function that uploads files to S3 locally using LocalStack. This lab demonstrates multiple deployment methods — Terraform, CloudFormation, and Boto3.

  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. Run the Example:

    Terminal window
    python main.py

There are other deployment methods you can use in this lab.

Terminal window
scripts/terraform/deploy.sh
  • Check S3 Bucket:
    Terminal window
    aws s3 ls s3://test-bucket/ --profile localstack
  • View Lambda Logs:
    Terminal window
    aws logs tail /aws/lambda/upload-to-s3 --profile localstack

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

Terminal window
scripts/terraform/destroy.sh

To remove all containers and volumes as well:

Terminal window
docker compose down -v
IssueSolution
Lambda TimeoutEnsure LocalStack has enough memory and CPU resources.
Connection RefusedEnsure LocalStack is running and wait for the Ready. message in logs.