AWS S3 Bucket Local Testing Using LocalStack
In this article, We will show you how you can use LocalStack to test AWS S3 Bucket on your local system.

Summary
This article demonstrates how to use LocalStack to test AWS S3 Bucket locally on your system.
Abstract
The article explains the use of LocalStack, a testing/mocking framework for developing Cloud applications, to test AWS cloud resources locally. LocalStack spins up core Cloud APIs on your local machine, including S3, and provides benefits such as cost reduction, local testing, learning, and debugging. The article provides a step-by-step guide on setting up LocalStack using Docker, creating a docker-compose.yml file, and testing services like S3 bucket creation and file upload. It also recommends using Commandeer to verify the S3 bucket and file creation.
Opinions
In this article, We will show you how you can use LocalStack to test AWS S3 Bucket on your local system.

LocalStack provides an easy-to-use test/mocking framework for developing Cloud applications. This means you can test AWS cloud resources locally on your machine.
Note: LocalStack supporting only AWS cloud stack.
LocalStack spins up the following core Cloud APIs on your local machine.
We hope you have installed Docker on your system else you can check the following article to install Docker.
Note: Starting with version 0.11.0, all APIs are exposed via a single edge service, which is accessible on http://localhost:4566 by default. If you look into the following file we have used EDGE_PORT=4566.
In the above file, We are creating 2 Services as below with default region us-east-1
If you run the following command
docker-compose up
You will see the LocalStack container is running successfully
To check all the services type the following URL on your browser
http://localhost:4566/health

if you look at the above screenshot 4 services are running
But in our docker-compose.yml file, we have added only 2 services which are
With lambda service logs and cloud watch service enabled by default.
Make sure you have installed AWS client on your system if not you can follow the following link to install
Once your LocalStack container is running up. You can open a new terminal and create an S3 Bucket using following command
aws --endpoint-url=http://localhost:4566 s3 mb s3://onexlabThe above command will create the S3 bucket onexlab in the LocalStack S3 bucket.

We have created one file text-test.txt as shown below in the screenshot

to upload text-test.txt to the S3 bucket using the following command
aws --endpoint-url=http://localhost:4566 s3 cp text-test.txt s3://onexlabThe above command will copy the file to the S3 bucket

You can verify using the below command S3 bucket contains files
aws --endpoint-url=http://localhost:4566 s3 ls s3://onexlab
we are using Commandeer to check the S3 bucket and the File has been created succefully.


Thank you 🚀🚀🚀🚀
Amanda QuintSchedule your workflows using Infrastructure as Code (IAC).
Brian HulelaSecurely upload files to an s3 bucket without exposing your credentials.