Skip to content

Commit 044e116

Browse files
committed
1 parent 9b4f16b commit 044e116

4 files changed

Lines changed: 198 additions & 0 deletions

File tree

_data/authors.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,3 +645,11 @@ tom_spencer:
645645
description: "Tom is a Software Engineer at Capgemini, with an interest in security, web applications and cloud computing"
646646
avatar: /images/authors/tom-spencer.jpeg
647647
team: java
648+
charles_ofoegbu:
649+
name: Tochukwu (Charles) Ofoegbu
650+
github: cofoegbu
651+
linkedin: http://uk.linkedin.com/in/tcofoegbu
652+
description: "Charles is a Software Engineer at Capgemini, with an interest in delivering software solutions efficiently through automation and cloud technologies."
653+
avatar: /images/authors/charles-ofoegbu.jpeg
654+
team: java
655+
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
layout: post
3+
title: "Accelerating AWS Native Development with LocalStack & Docker: A Real-World Case Study"
4+
summary: "Some of the benefits of using LocalStack to emulate AWS environments on a developer's local machine, based on real-world project experience."
5+
category: Cloud
6+
tags: [AWS, Cloud, Development, Testing]
7+
author: [charles_ofoegbu]
8+
comments: true
9+
share: true
10+
---
11+
12+
13+
In this blog post, I'll walk through how using [LocalStack](https://www.localstack.cloud/) with [Docker](https://www.docker.com/)
14+
and [Docker Compose](https://docs.docker.com/compose/) helped us speed up development
15+
and testing, making the entire process more efficient and seamless.
16+
17+
When building modern cloud-native applications on AWS, having a reliable and cost-effective approach
18+
to development and testing is essential.
19+
For this project, we utilised LocalStack, a platform that simulates AWS services locally. This
20+
enabled us to work more efficiently, speed up development, cut down on costs, and quickly test
21+
integrations without constantly interacting with the actual AWS cloud. LocalStack, along with other
22+
components of the project, was deployed as Docker containers using Docker Compose for
23+
orchestrating the entire environment locally.
24+
25+
## The Challenge: Cloud Dependency Slows Development
26+
As many developers will attest, working directly with live AWS services can become costly and slow.
27+
Every API call, infrastructure change, or even basic testing, requires interaction with the cloud,
28+
which can introduce delays. On top of that, maintaining isolation between development and production
29+
environments can be tricky and costly when dealing with real AWS resources.
30+
31+
In particular, this project was fast-paced and required frequent iteration between components. This
32+
constant cycle of making changes, pushing updates, and testing in a live AWS environment was prone
33+
to introduce a lot of friction. A local alternative to AWS was essential for reducing the turnaround
34+
time between code changes and testing. The combination of LocalStack with Docker and Docker Compose
35+
provided the perfect solution.
36+
37+
## The Solution: LocalStack with Docker
38+
**[LocalStack](https://www.localstack.cloud/)** — "A complete, localised AWS environment where developers can build, test,
39+
profile and debug infrastructure and code ahead of deployment to the cloud." By deploying LocalStack
40+
in a Docker container, we were able to spin up a local version of AWS that was fast, reliable, and
41+
cost-free. Docker made it easy to manage and isolate the LocalStack environment, while Docker Compose
42+
orchestrated the entire environment locally, allowing us to run all components — front-end, back-end,
43+
mocks, and infrastructure, together in one seamless, local environment without the latency, cost, or
44+
need for an internet connection.
45+
46+
### Project Overview
47+
The project consisted of four key components:
48+
1. **UI Component:** The frontend / user interface of the application was developed with
49+
[Node.Js](https://nodejs.org/en) and [Nunjucks](https://mozilla.github.io/nunjucks/) used as the templating engine.
50+
2. **Backend Component:** The APIs and business logic built with [Java](https://www.java.com/en/)
51+
and [Spring Boot](https://spring.io/projects/spring-boot) framework
52+
3. **Mock Component:** A HTTP mock service based on [MockServer](https://www.mock-server.com/) used to simulate third-party
53+
or Upstream APIs.
54+
4. **Infrastructure/Environment:** The AWS environment was defined in code following the
55+
Infrastructure as Code (IaC) paradigm, using [Terraform](https://www.terraform.io/) to provision various AWS services.
56+
57+
![Basic High level illustration of project setup with local stack, docker and docker compose](/images/2024-11-08-aws-native-dev/LocalStack_Project_Illustration.drawio.png)
58+
59+
In this project, we used **SQS** for messaging, **S3** for object storage, and **ECS** for container
60+
orchestration, **Cognito** for user management, **Cloud Watch** for monitoring and alerting, among
61+
other AWS services. LocalStack allowed us to simulate these services locally, cutting down
62+
on our cloud costs and speeding up development. With Docker and Docker Compose, all services were
63+
integrated into a single, local environment that closely mirrored the cloud environment.
64+
For instance:
65+
- Messaging flows were tested by sending and receiving messages through **local SQS queues**. This
66+
allowed us to validate the flow of messages from one component to another, ensuring that the
67+
message-handling logic worked as expected.
68+
- We uploaded and retrieved files from LocalStack’s simulated **S3 buckets**, ensuring our storage
69+
logic worked as expected without needing to interact with the actual AWS S3 service
70+
- User authorisation and authentication was tested through local **Cognito User Pools**
71+
- Our back-end API integrated with Mock services simulated using **MockServer** running in
72+
Docker, allowing us to test data storage and retrieval workflows without needing the live services
73+
deployed on AWS.
74+
75+
All the code for the various components were managed with [Git](https://git-scm.com/) & [GitLab](https://about.gitlab.com/) version control,
76+
and we also utilised GitLab’s CI/CD for our build and deployment pipeline management.
77+
78+
Refer to [AWS Service Feature Coverage](https://docs.localstack.cloud/user-guide/aws/feature-coverage/)
79+
for an overview of the AWS APIs and services implemented in LocalStack
80+
81+
## LocalStack and Docker enhanced our project in the following ways:
82+
83+
### 1. Containerised Deployment
84+
By containerising LocalStack, our application’s Backend services, Frontend service, mock components,
85+
and other services, we could deploy the entire stack on any developer's machine with minimal setup.
86+
All that was required was Docker and Docker Compose. This approach offered consistency across
87+
different environments and eliminated the "works on my machine" issues that often arise when
88+
different developers have different local setups.
89+
90+
### 2. Docker Compose for Orchestration
91+
We used Docker Compose to orchestrate our multi-container environment. Each service—whether it was
92+
LocalStack simulating AWS or our front-end and back-end components—was defined in a single
93+
docker-compose.yml file. With one command, we could spin up or tear down the entire environment.
94+
This orchestration allowed us to develop, test, and debug the entire system on a local machine
95+
without having to interact with AWS cloud services.
96+
97+
Here’s an example of the Docker Compose setup. Please note, this is just an illustration and not the
98+
actual configuration.
99+
```
100+
version: '3'
101+
services:
102+
localstack:
103+
image: localstack/localstack
104+
ports:
105+
- "4566:4566"
106+
- "4571:4571"
107+
environment:
108+
- SERVICES=s3,sqs,lambda,dynamodb
109+
volumes:
110+
- "/var/run/docker.sock:/var/run/docker.sock"
111+
112+
backend:
113+
build: ./backend
114+
depends_on:
115+
- localstack
116+
ports:
117+
- "5000:5000"
118+
119+
frontend:
120+
build: ./frontend
121+
ports:
122+
- "3000:3000"
123+
124+
mock-service:
125+
build: ./mock-service
126+
ports:
127+
- "4000:4000"
128+
```
129+
130+
This setup allowed all components — LocalStack, the back-end, front-end, and mock services to run in
131+
harmony, facilitating rapid development and easy integration testing.
132+
133+
### 3. Faster Development Cycle
134+
By running services locally, we no longer had to wait for deployments or API interactions to happen
135+
in the cloud. We could iterate over changes rapidly, test out new features, and deploy code without
136+
worrying about cloud costs. For example, instead of sending messages through live SQS queues and
137+
interacting with S3 storage on AWS, LocalStack let us simulate these services locally. This allowed
138+
us to run and test our messaging workflows much faster.
139+
140+
### 4. Easy Integration Testing
141+
One of the biggest challenges in modern cloud applications is ensuring that various components —
142+
front-end, back-end, messaging, storage; are working harmoniously together. LocalStack made this
143+
process seamless. Since we could emulate all the AWS services locally, we could simulate how our
144+
front-end communicated with the back-end, how our back-end processed data using SQS and stored files
145+
in S3, and even how our infrastructure interacted with external services. This allowed us to test
146+
integrations between various parts of our system without needing to push anything to the cloud.
147+
148+
### 5. Reduced Costs
149+
The ability to test AWS-dependent services locally means you’re not accumulating unnecessary cloud
150+
charges. In our project, running constant tests on live AWS services would have significantly
151+
increased the budget. LocalStack helped us minimize these costs by simulating the AWS environment on
152+
our local machines without any cloud interaction. This is particularly useful for small teams or
153+
projects with limited budgets.
154+
155+
### 6. Simplified Infrastructure Setup
156+
LocalStack also simplifies the process of setting up and tearing down infrastructure. Since
157+
everything runs locally, we could quickly spin up and shut down environments for testing and
158+
development, reducing the overhead involved in managing cloud resources.
159+
160+
### 7. Parallel Development
161+
With LocalStack in place, our team could develop multiple components simultaneously. The front-end
162+
devs didn't need to wait for the back-end APIs to be fully functional in AWS; they could test against
163+
the locally mocked services. Similarly, the infrastructure devs could configure and test various AWS
164+
services locally before pushing changes to the cloud.
165+
166+
## Downsides of LocalStack:
167+
168+
### 1. Limited Feature Support
169+
Not all AWS services and features may be available or fully supported in LocalStack. Also, new or
170+
complex features may not be fully implemented, which could impact testing and development.
171+
172+
### 2. Compatibility Concerns
173+
LocalStack may not always be fully compatible with the latest versions of AWS SDKs which could lead
174+
to delays in adopting new features.
175+
176+
### 3. Configuration Complexity
177+
Configuring and setting up LocalStack may require additional effort and technical know how. It may
178+
not be as straightforward as using the actual cloud services, especially for beginners.
179+
180+
## Conclusion
181+
In summary, LocalStack significantly accelerated our project’s development and testing processes. By
182+
simulating a local AWS environment, it allowed us to quickly iterate on our front-end, back-end, and
183+
infrastructure components without incurring high cloud costs or waiting for slow cloud interactions.
184+
185+
I would highly recommend incorporating LocalStack into your workflow for anyone working on projects
186+
that rely on AWS services. Not only will it make your development process faster and more efficient,
187+
but it will also allow you to test AWS integrations with greater confidence, all while keeping your
188+
costs low. If you haven’t tried LocalStack yet, give it a shot - you’ll likely find it as invaluable
189+
as we did!
190+
176 KB
Loading
31.3 KB
Loading

0 commit comments

Comments
 (0)