LocalStack Interacting with Client Code

Search for a command to run...

No comments yet. Be the first to comment.
Bite-size LocalStack features inspired by frequently asked questions. Each post zooms in on a single example-backed topic, unlocking insights to elevate user knowledge and pave the path to success.
Alright, let's get real for a moment. This one's a PSA, folks. We're diving into that elusive puzzle piece you might have missed in your docker-compose files. You know the one that's been quietly driving you nuts? Yeah, we've been there too. And hey,...
Learn how to test the EventBridge archive and replay feature with a Lambda target using LocalStack and AWS CLI — all on your local machine.

Learn how to deploy and debug ECS tasks locally with LocalStack by attaching a remote debugger in VS Code to facilitate local development & testing!

Learn how to run an EC2 instance using LocalStack's core cloud emulator and AWS CLI to facilitate development & testing right on your local machine!

Introduction In today’s tech landscape, large language models (LLMs) and AI are transforming both tech-centric and traditional businesses. AI functionality is being integrated across various platforms to enhance user experience. However, developing a...

After seeing how LocalStack Cloud Pods help teams work better together, let's look at the other ways companies can keep their snapshots in their own court. For environments with stricter security policies, there are a few storage options that help pr...

Using Docker for local development offers several advantages: isolation, consistency, reproducibility, efficiency, portability, easy cleanup, and security. You get the gist.
These are also the great advantages of LocalStack shipping as a Docker image.
Let’s say your product is a multi-functional web application that does all sorts of operations for your clients. The backend is handled by AWS-managed services, so your main focus is providing the best user experience possible. For the development phase, your setup would look something like this diagram, the center of attention being the React app, while the rest are necessary dependencies:

A new frontend engineer is joining the team and they want to get their setup running as fast as possible so that they can start making much-needed improvements to the app. Of course, they would say that talk is cheap, they want to see the code:
Clone the repository:
git clone https://github.com/tinyg210/stack-bytes-apigw-lambda-s3.git
Switch to the module folder:
cd stack-bytes-apigw-lambda-s3/frontend-client-local-machine
Run the preconfigured docker-compose file in detached mode:
docker compose up -d
Install the React app dependencies:
npm install
Run the web application:
npm start
That’s it. In just five easy steps your new developer can start understanding and working on the app. No need for days of waiting to obtain all the necessary credentials and permissions for a new AWS account and no accidental cost spikes for learning purposes.

We can now see that our sophisticated app is running on localhost:3000. It is communicating with the API Gateway, which uses 2 separate Lambdas for creating and fetching, and an S3 bucket for storing the text files that contain the quotes that we want to remember forever. The reason why everything was so fast is a combination of features that are there to enhance the developer experience. The docker-compose file simply requests the LocalStack image, makes sure the right ports are exposed, and adds some configs regarding the network and access to the Docker socket (we’ll talk about it soon). But the more important parts lay in these lines:
volumes:
- "../stack-bytes-lambda/target/apigw-lambda.jar:/etc/localstack/init/ready.d/target/apigw-lambda.jar"
- "../init-resources.sh:/etc/localstack/init/ready.d/init-resources.sh"
These are the init hooks that ensure the needed resources are created at startup.
From here on, the endpoints are quickly configured for local development, and everything is set:

Notice how fast getting someone onboarded is. This combination facilitates swift resource replication across multiple environments, enabling rapid team integration and productive collaboration. 👍