11# Shipment List Demo Application - AWS in PROD and LocalStack on DEV environment
22
3+ <img src="https://img.shields.io/badge/LocalStack-deploys-4D29B4.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKgAAACoABZrFArwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAALbSURBVHic7ZpNaxNRFIafczNTGIq0G2M7pXWRlRv3Lusf8AMFEQT3guDWhX9BcC/uFAr1B4igLgSF4EYDtsuQ3M5GYrTaj3Tmui2SpMnM3PlK3m1uzjnPw8xw50MoaNrttl+r1e4CNRv1jTG/+v3+c8dG8TSilHoAPLZVX0RYWlraUbYaJI2IuLZ7KKUWCisgq8wF5D1A3rF+EQyCYPHo6Ghh3BrP8wb1en3f9izDYlVAp9O5EkXRB8dxxl7QBoNBpLW+7fv+a5vzDIvVU0BELhpjJrmaK2NMw+YsIxunUaTZbLrdbveZ1vpmGvWyTOJToNlsuqurq1vAdWPMeSDzwzhJEh0Bp+FTmifzxBZQBXiIKaAq8BBDQJXgYUoBVYOHKQRUER4mFFBVeJhAQJXh4QwBVYeHMQJmAR5GCJgVeBgiYJbg4T8BswYPp+4GW63WwvLy8hZwLcd5TudvBj3+OFBIeA4PD596nvc1iiIrD21qtdr+ysrKR8cY42itCwUP0Gg0+sC27T5qb2/vMunB/0ipTmZxfN//orW+BCwmrGV6vd63BP9P2j9WxGbxbrd7B3g14fLfwFsROUlzBmNM33XdR6Meuxfp5eg54IYxJvXCx8fHL4F3w36blTdDI4/0WREwMnMBeQ+Qd+YC8h4g78wF5D1A3rEqwBiT6q4ubpRSI+ewuhP0PO/NwcHBExHJZZ8PICI/e73ep7z6zzNPwWP1djhuOp3OfRG5kLROFEXv19fXP49bU6TbYQDa7XZDRF6kUUtEtoFb49YUbh/gOM7YbwqnyG4URQ/PWlQ4ASllNwzDzY2NDX3WwioKmBgeqidgKnioloCp4aE6AmLBQzUExIaH8gtIBA/lFrCTFB7KK2AnDMOrSeGhnAJSg4fyCUgVHsolIHV4KI8AK/BQDgHW4KH4AqzCQwEfiIRheKKUAvjuuu7m2tpakPdMmcYYI1rre0EQ1LPo9w82qyNziMdZ3AAAAABJRU5ErkJggg=="> <img src="https://img.shields.io/badge/AWS-deploys-F29100.svg?logo=amazon">
4+
35### Prerequisites
6+
47- Maven 3.8.5 & Java 17
58- AWS free tier account
69- Docker - for running LocalStack
912
1013## Purpose
1114
12- This application was conceived for demonstration purposes to highlight the ease of switching from
13- using actual AWS dependencies to having them emulated on LocalStack for your * developer environment* .
15+ This application was conceived for demonstration purposes to highlight the ease of switching from
16+ using actual AWS dependencies to having them emulated on LocalStack for your * developer environment*
17+ .
1418Of course this comes with other advantages, but the first focus point is making the transition.
1519
1620## What it does
1721
18- * shipment-list-demo* is a Spring Boot application dealing with CRUD operations an employee can execute
22+ * shipment-list-demo* is a Spring Boot application dealing with CRUD operations an employee can
23+ execute
1924on a bunch of shipments that they're allowed to view - think of it like the Post app.
20- The demo consists of a backend and a frontend implementation, using React to display the information.
25+ The demo consists of a backend and a frontend implementation, using React to display the
26+ information.
2127The AWS services involved are:
22- - S3 for storing pictures
23- - DynamoDB for the entities
24- - Lambda function that will validate the pictures.
28+
29+ - S3 for storing pictures
30+ - DynamoDB for the entities
31+ - Lambda function that will validate the pictures.
2532
2633## How it works
2734
2835![ Diagram] ( app_diagram.png )
2936
3037## How we will be using it
31- We’ll be walking through a few scenarios using the application, and we expect it to maintain the
38+
39+ We’ll be walking through a few scenarios using the application, and we expect it to maintain the
3240behavior in both production and development environments.
33- We’ll take advantage of one of the core features of the Spring framework that allows us to bind our
34- beans to different profiles, such as dev, test, and prod. Of course, these beans need to know how to
35- behave in each environment, so they’ll get that information from their designated configuration files,
41+ We’ll take advantage of one of the core features of the Spring framework that allows us to bind our
42+ beans to different profiles, such as dev, test, and prod. Of course, these beans need to know how to
43+ behave in each environment, so they’ll get that information from their designated configuration
44+ files,
3645` application-prod.yml ` , and ` application-dev.yml ` .
3746
3847## Running it
3948
4049### Production simulation
4150
42- Now we don’t have a real production environment because that’s not the point here, but most likely,
43- an application like this runs on a container orchestration platform, and all the necessary configs
44- are still provided. Since we’re only simulating a production instance, all the configurations are
51+ Now we don’t have a real production environment because that’s not the point here, but most likely,
52+ an application like this runs on a container orchestration platform, and all the necessary configs
53+ are still provided. Since we’re only simulating a production instance, all the configurations are
4554kept in the ` application-prod.yml ` file.
4655
4756Before getting started, it's important to note that an IAM user, who's credentials will be used,
4857needs to be created with the following policies:
58+
4959- AmazonS3FullAccess
5060- AWSLambda_FullAccess
5161- AmazonDynamoDBFullAccess
@@ -57,44 +67,54 @@ At startup @dynamobee helps set up the table we need and populate it with some s
5767The changelog acts as a database version control. It tracks all the changes made to the database,
5868and helps you manage database migration.
5969
60- To run the backend simply use
70+ To run the backend simply use
71+
6172```
6273mvn spring-boot:run -Dspring-boot.run.profiles=prod
6374```
6475
6576Now ` cd ` into ` src/main/shipment-list-frontend ` and run ` npm install ` and ` npm start ` .
6677This will spin up the React app that can be accessed on ` localhost:3000 ` .
6778
68- You should now be able to see a list of shipments with standard icons, that means that only the database
79+ You should now be able to see a list of shipments with standard icons, that means that only the
80+ database
6981is populated, the pictures still need to be added from the ` sample-pictures ` folder.
7082The weight of a shipment we can perceive, but not the size, that's why we need to display it,
7183using the "banana for scale" measuring unit. How else would we know??
7284
7385The Lambda function is still not up. This falls under the ` shipment-list-lambda-validator ` project.
86+
7487```
7588git clone https://github.com/tinyg210/shipment-list-lambda-validator.git
7689```
7790
78- The ` create-lambda.sh ` script will do everything that needs for the creation and configuration of the
91+ The ` create-lambda.sh ` script will do everything that needs for the creation and configuration of
92+ the
7993Lambda. (I know what you're thinking, Terraform will follow.)
80- Run ` add-notif-config-for-lambda.sh ` , but before that remember to edit ` notification-config.json ` with
81- your own AWS account ID. This will enable the Lambda to receive notifications every time a picture is being
94+ Run ` add-notif-config-for-lambda.sh ` , but before that remember to edit ` notification-config.json `
95+ with
96+ your own AWS account ID. This will enable the Lambda to receive notifications every time a picture
97+ is being
8298added to S3.
8399
84- You should now be able to add a new picture for each shipment. Files that are not pictures will be deleted
100+ You should now be able to add a new picture for each shipment. Files that are not pictures will be
101+ deleted
85102and the shipment picture will be replaced with a generic icon.
86103
87104### Developer environment
88105
89- To switch to using LocalStack instead of AWS services just run ` docker compose up ` to spin up a Localstack
106+ To switch to using LocalStack instead of AWS services just run ` docker compose up ` to spin up a
107+ Localstack
90108container.
91109After that, the Spring Boot application needs to start using the dev profile:
110+
92111```
93112mvn spring-boot:run -Dspring-boot.run.profiles=dev
94113```
95114
96115This should again populate the DynamoDB, this time on LocalStack.
97- From here on, the rest of the steps are the same, but all the scripts that need to run end in ` -local ` ,
116+ From here on, the rest of the steps are the same, but all the scripts that need to run end
117+ in ` -local ` ,
98118as they use the ` awslocal ` CLI.
99119
100120The same actions should be easily achieved again, but locally.
0 commit comments