Skip to content

Commit a86013e

Browse files
razvan minciunarazvan minciuna
razvan minciuna
authored and
razvan minciuna
committed
Initial Commit
0 parents  commit a86013e

15 files changed

+812
-0
lines changed

.gitignore

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
.idea/
2+
# User-specific stuff
3+
.idea/**/workspace.xml
4+
.idea/**/tasks.xml
5+
.idea/**/usage.statistics.xml
6+
.idea/**/dictionaries
7+
.idea/**/shelf
8+
9+
.DS_Store
10+
11+
# AWS User-specific
12+
.idea/**/aws.xml
13+
14+
# Generated files
15+
.idea/**/contentModel.xml
16+
17+
# Sensitive or high-churn files
18+
.idea/**/dataSources/
19+
.idea/**/dataSources.ids
20+
.idea/**/dataSources.local.xml
21+
.idea/**/sqlDataSources.xml
22+
.idea/**/dynamic.xml
23+
.idea/**/uiDesigner.xml
24+
.idea/**/dbnavigator.xml
25+
26+
# Gradle
27+
.idea/**/gradle.xml
28+
.idea/**/libraries
29+
30+
31+
# CMake
32+
cmake-build-*/
33+
34+
# Mongo Explorer plugin
35+
.idea/**/mongoSettings.xml
36+
37+
# File-based project format
38+
*.iws
39+
40+
# IntelliJ
41+
out/
42+
43+
# mpeltonen/sbt-idea plugin
44+
.idea_modules/
45+
46+
# JIRA plugin
47+
atlassian-ide-plugin.xml
48+
49+
# Cursive Clojure plugin
50+
.idea/replstate.xml
51+
52+
# SonarLint plugin
53+
.idea/sonarlint/
54+
55+
# Crashlytics plugin (for Android Studio and IntelliJ)
56+
com_crashlytics_export_strings.xml
57+
crashlytics.properties
58+
crashlytics-build.properties
59+
fabric.properties
60+
61+
# Editor-based Rest Client
62+
.idea/httpRequests
63+
64+
# Android studio 3.1+ serialized cache file
65+
.idea/caches/build_file_checksums.ser
66+
67+
# Compiled class file
68+
*.class
69+
70+
# Log file
71+
*.log
72+
73+
# BlueJ files
74+
*.ctxt
75+
76+
# Mobile Tools for Java (J2ME)
77+
.mtj.tmp/
78+
79+
# Package Files #
80+
*.jar
81+
82+
# Target
83+
target/
84+
*.war
85+
*.nar
86+
*.ear
87+
*.zip
88+
*.tar.gz
89+
*.rar
90+
91+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
92+
hs_err_pid*

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
## CHOREOGRAPHY Pattern - AWS Serverless - Java
2+
3+
This is a Java implementation of the CHOREOGRAPHY Pattern using AWS Serverless services.
4+
5+
<img src="choreography.png" alt="" width="50%"/>
6+
7+
#### Description
8+
9+
This is a basic representation and implementation of the Choreography pattern.
10+
In Microservice architecture the application is divided in small services which are responsible for a singe business subdomain.
11+
When these services need to communicate with each other there are several ways and different communication styles.
12+
The Choreography pattern is one of them.
13+
14+
The SAM template contains all the information to deploy AWS resources and also the permission required by these service to communicate.
15+
16+
You will be able to create and delete the CloudFormation stack using AWS SAM.
17+
18+
This is fully functional example implemented in Java 11.
19+
20+
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details. You are responsible for any AWS costs incurred.
21+
22+
#### Language:
23+
#### This is a Maven project which uses Java 11 and AWS SDK
24+
25+
#### Framework
26+
The framework used to deploy the infrastructure is SAM
27+
28+
#### Services used
29+
30+
#### API Gateway - AWS Lambda - DynamoDB
31+
32+
#### Deployment commands
33+
34+
````
35+
mvn clean package
36+
37+
aws s3 mb s3://hifo8q34hfksdjnfpqwf
38+
39+
aws s3 cp target/sourceCode.zip s3://hifo8q34hfksdjnfpqwf
40+
41+
sam deploy --s3-bucket hifo8q34hfksdjnfpqwf --stack-name choreography-pattern --capabilities CAPABILITY_IAM
42+
````
43+
44+
Add cinemas and movies in DynamoDB tables
45+
````
46+
aws dynamodb batch-write-item --request-items file://./dynamodb/movies.json
47+
48+
aws dynamodb batch-write-item --request-items file://./dynamodb/cinemas.json
49+
````
50+
51+
#### TESTING
52+
53+
Copy the URL from the SAM Outputs:
54+
CloudFormation outputs from deployed stack
55+
56+
Key PaymentsEndpoint
57+
Description API Gateway Cinema Endpoint
58+
Value https://XXXXXXXX.execute-api.XXXXXXXXXX.amazonaws.com/prod/cinema
59+
60+
Add the cinemaID/movies at the end of the URL. cinemaID available: aaaa and bbbb
61+
62+
````
63+
curl https://XXXXXXXX.execute-api.XXXXXXXX.amazonaws.com/prod/cinema/aaaa/movies -H "Accept: application/json"
64+
65+
curl https://XXXXXXXX.execute-api.XXXXXXXX.amazonaws.com/prod/cinema/bbbb/movies -H "Accept: application/json"
66+
````
67+
68+
#### CLEAN-UP
69+
70+
71+
````
72+
aws cloudformation delete-stack --stack-name choreography-pattern
73+
74+
aws s3 rm s3://hifo8q34hfksdjnfpqwf --recursive
75+
76+
aws s3 rb s3://hifo8q34hfksdjnfpqwf
77+
````
78+
#### Requirements
79+
80+
* [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
81+
* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured
82+
* [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed
83+
84+
#### Author
85+
Razvan Minciuna
86+
https://www.linkedin.com/in/razvanminciuna/

choreography.png

53.8 KB
Loading

dynamodb/cinemas.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"CinemasTable": [
3+
{
4+
"PutRequest": {
5+
"Item": {
6+
"cinemaId": {"S": "aaaa"},
7+
"name": {"S": "Golden Star"},
8+
"movies": {
9+
"L": [
10+
{
11+
"S": "2222"
12+
},
13+
{
14+
"S": "4444"
15+
},
16+
{
17+
"S": "5555"
18+
}
19+
]
20+
}
21+
}
22+
}
23+
},
24+
{
25+
"PutRequest": {
26+
"Item": {
27+
"cinemaId": {"S": "bbbb"},
28+
"name": {"S": "Entertainment Theatre"},
29+
"movies": {
30+
"L": [
31+
{
32+
"S": "1111"
33+
},
34+
{
35+
"S": "3333"
36+
},
37+
{
38+
"S": "6666"
39+
}
40+
]
41+
}
42+
}
43+
}
44+
}
45+
]
46+
}

dynamodb/movies.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"MoviesTable": [
3+
{
4+
"PutRequest": {
5+
"Item": {
6+
"movieId": {"S": "1111"},
7+
"title": {"S": "Three and a half men"},
8+
"genre": {"S": "comedy"}
9+
}
10+
}
11+
},
12+
{
13+
"PutRequest": {
14+
"Item": {
15+
"movieId": {"S": "2222"},
16+
"title": {"S": "Batman"},
17+
"genre": {"S": "action"}
18+
}
19+
}
20+
},
21+
{
22+
"PutRequest": {
23+
"Item": {
24+
"movieId": {"S": "3333"},
25+
"title": {"S": "Seinfeld"},
26+
"genre": {"S": "comedy"}
27+
}
28+
}
29+
},
30+
{
31+
"PutRequest": {
32+
"Item": {
33+
"movieId": {"S": "4444"},
34+
"title": {"S": "Die Hard"},
35+
"genre": {"S": "action"}
36+
}
37+
}
38+
},
39+
{
40+
"PutRequest": {
41+
"Item": {
42+
"movieId": {"S": "5555"},
43+
"title": {"S": "Millions"},
44+
"genre": {"S": "drama"}
45+
}
46+
}
47+
},
48+
{
49+
"PutRequest": {
50+
"Item": {
51+
"movieId": {"S": "6666"},
52+
"title": {"S": "Matrix"},
53+
"genre": {"S": "sci-fi"}
54+
}
55+
}
56+
}
57+
]
58+
}

lambda-zip.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0
4+
http://maven.apache.org/xsd/assembly-2.0.0.xsd">
5+
<id>lambda-zip</id>
6+
<formats>
7+
<format>zip</format>
8+
</formats>
9+
<includeBaseDirectory>false</includeBaseDirectory>
10+
<dependencySets>
11+
<dependencySet>
12+
<includes>
13+
<include>${project.groupId}:${project.artifactId}</include>
14+
</includes>
15+
<unpack>true</unpack>
16+
<unpackOptions>
17+
<excludes>
18+
<exclude>META-INF/MANIFEST.MF</exclude>
19+
<exclude>META-INF/maven/**</exclude>
20+
</excludes>
21+
</unpackOptions>
22+
</dependencySet>
23+
<dependencySet>
24+
<useProjectArtifact>false</useProjectArtifact>
25+
<unpack>false</unpack>
26+
<scope>runtime</scope>
27+
<outputDirectory>lib</outputDirectory>
28+
</dependencySet>
29+
</dependencySets>
30+
</assembly>

0 commit comments

Comments
 (0)