Build: Simulate S3 on Your Local Linux Machine with LocalStack
When
you're working with AWS S3, you're typically interacting with a remote cloud
environment. But what if you want to test file uploads, downloads, and bucket
permissions — all without touching the internet? That’s where LocalStack
shines. It lets you spin up a local mock version of AWS, including services
like S3, using nothing but your own Linux machine.
In this tutorial, everything happens locally: one machine, one terminal, and no cloud dependency. You'll create a bucket, upload a file, download it again, and confirm that it all works — just like it would on AWS.
Before you begin, make sure you’ve already installed LocalStack and set up a Python virtual environment. We’ll assume your virtual environment is named localstack-venv, as described in our earlier post. Follow this guide to install LocalStack on Debian-based Linux if you haven’t done that step yet.
Once the environment is ready, activate it:
All commands in this tutorial will be run from within the virtual
environment.
From here, we’ll start LocalStack, configure the AWS CLI, and create your first local S3 bucket.
In this tutorial, everything happens locally: one machine, one terminal, and no cloud dependency. You'll create a bucket, upload a file, download it again, and confirm that it all works — just like it would on AWS.
Before you begin, make sure you’ve already installed LocalStack and set up a Python virtual environment. We’ll assume your virtual environment is named localstack-venv, as described in our earlier post. Follow this guide to install LocalStack on Debian-based Linux if you haven’t done that step yet.
Once the environment is ready, activate it:
From here, we’ll start LocalStack, configure the AWS CLI, and create your first local S3 bucket.
1. Start LocalStack
Make sure LocalStack is running. You can start it like this:
Wait for the terminal to show that services are up. You'll see a Ready. message in the termial. You’re now running a local version of AWS. Note that LocalStack is running in the foreground and will display log messages to your current terminal. So to continue this tutorial, you'll start up a second Linux terminal to enter LocalStack commands.
Make sure LocalStack is running. You can start it like this:
Wait for the terminal to show that services are up. You'll see a Ready. message in the termial. You’re now running a local version of AWS. Note that LocalStack is running in the foreground and will display log messages to your current terminal. So to continue this tutorial, you'll start up a second Linux terminal to enter LocalStack commands.
2. Set Up Your AWS CLI for LocalStack
In a second Linux terminal, tell the AWS CLI to use test credentials and LocalStack’s local endpoint. Each line sets one environment variable, and you should enter them one at a time:
The access key ID is like your AWS login:
The secret access key is like your AWS password:
And the region determines the default service region:
These test credentials work only with LocalStack and are not
linked to any real AWS account.
When using aws commands with LocalStack, you'll need to include the --endpoint-url flag to tell the CLI where to send requests. Here's an example of how to include it:
Alternatively, use awslocal, which includes the endpoint URL by
default. For example, instead of writing:
You can simply run:
This makes your commands shorter and easier to read.
In a second Linux terminal, tell the AWS CLI to use test credentials and LocalStack’s local endpoint. Each line sets one environment variable, and you should enter them one at a time:
The access key ID is like your AWS login:
When using aws commands with LocalStack, you'll need to include the --endpoint-url flag to tell the CLI where to send requests. Here's an example of how to include it:
3. Create
an S3 Bucket
Now create a new bucket called my-local-bucket using the mb command, which stands for make bucket:
You’ll see a confirmation that the bucket was created.
Now create a new bucket called my-local-bucket using the mb command, which stands for make bucket:
4. Upload a File
Make a quick text file:
Then upload it to the bucket:
Verify the upload using ls:
Expected output:
5. Download the File
To verify, remove the file locally:
And re-download it. The final period . means the file will be downloaded
to your current working directory:
List the contents of your local directory to verify the download:
Expected output:
Check the contents of the file:
You should see:
6. Deactivate the Virtual Environment
When you're done, you can exit the virtual environment by running:
This returns your shell to its original state.
Make a quick text file:
To verify, remove the file locally:
When you're done, you can exit the virtual environment by running:
Conclusion: You’re Now Simulating AWS on Your Own Terms
That’s your end-to-end S3 simulation, right on your Linux box — no SSH, no AWS, no cloud costs. Just a local dev playground that behaves like the real thing. From here, you can branch out into event-driven workflows, Lambda emulation, and more.
Need AWS Expertise?
We'd love to help you with your AWS projects. Feel free to reach out to us at info@pacificw.com.
Written by Aaron Rose, software engineer and technology writer at Tech-Reader.blog.
Comments
Post a Comment