Skip to content

Commit 08a549e

Browse files
containerizing project using localstack
1 parent dcd5f2f commit 08a549e

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
version: '3.7'
2+
3+
services:
4+
localstack:
5+
container_name: localstack
6+
image: localstack/localstack:3.3
7+
ports:
8+
- 4566:4566
9+
environment:
10+
- SERVICES=sns,sqs
11+
volumes:
12+
- ./localstack/init-sns-topic.sh:/etc/localstack/init/ready.d/init-sns-topic.sh
13+
- ./localstack/init-sqs-queue.sh:/etc/localstack/init/ready.d/init-sqs-queue.sh
14+
- ./localstack/subscribe-sqs-to-sns.sh:/etc/localstack/init/ready.d/subscribe-sqs-to-sns.sh
15+
networks:
16+
- reflectoring
17+
18+
user-management-service:
19+
container_name: user-management-service
20+
image: aws-pubsub-user-management-service
21+
ports:
22+
- 8080:8080
23+
depends_on:
24+
- localstack
25+
environment:
26+
spring.cloud.aws.sns.endpoint: 'http://localstack:4566'
27+
spring.cloud.aws.credentials.access-key: test
28+
spring.cloud.aws.credentials.secret-key: test
29+
spring.cloud.aws.sns.region: 'us-east-1'
30+
io.reflectoring.aws.sns.topic-arn: 'arn:aws:sns:us-east-1:000000000000:user-account-created'
31+
networks:
32+
- reflectoring
33+
34+
notification-dispatcher-service:
35+
container_name: notification-dispatcher-service
36+
image: aws-pubsub-notification-dispatcher-service
37+
ports:
38+
- 9090:8080
39+
depends_on:
40+
- localstack
41+
- user-management-service
42+
environment:
43+
spring.cloud.aws.sqs.endpoint: 'http://localstack:4566'
44+
spring.cloud.aws.credentials.access-key: test
45+
spring.cloud.aws.credentials.secret-key: test
46+
spring.cloud.aws.sqs.region: 'us-east-1'
47+
io.reflectoring.aws.sqs.queue-url: 'http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/dispatch-email-notification'
48+
networks:
49+
- reflectoring
50+
51+
networks:
52+
reflectoring:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
topic_name="user-account-created"
3+
4+
awslocal sns create-topic --name $topic_name
5+
6+
echo "SNS topic '$topic_name' created successfully"
7+
echo "Executed init-sns-topic.sh"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
queue_name="dispatch-email-notification"
3+
4+
awslocal sqs create-queue --queue-name $queue_name
5+
6+
echo "SQS queue '$queue_name' created successfully"
7+
echo "Executed init-sqs-queue.sh"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
topic_name="user-account-created"
3+
queue_name="dispatch-email-notification"
4+
5+
awslocal sns subscribe --topic-arn "arn:aws:sns:us-east-1:000000000000:$topic_name" --protocol sqs --notification-endpoint "arn:aws:sqs:us-east-1:000000000000:$queue_name"
6+
7+
echo "Subscribed SQS queue '$queue_name' to SNS topic '$topic_name' successfully"
8+
echo "Executed subscribe-sqs-to-sns.sh"

0 commit comments

Comments
 (0)