Skip to content

Commit 4d102ef

Browse files
starting on iter1
1 parent 8d9ce08 commit 4d102ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2150
-4
lines changed

aws-sdk-1/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
In which we build a *Roadmaps API* using:
44

55
* Java (11)
6-
* AWS Lambda, DynamoDB, API GW, SSM
6+
* AWS Lambda, DynamoDB, API GW, SSM by using the _AWS SDK for Java v1.x_
77
* Serverless.com
88

99
This project aims to show how to deploy a basic API using AWS serverless services, and [Serverless Framework](https://serverless.com) to deploy it.

aws-sdk-2/README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
In which we build a *Roadmaps API* using:
44

55
* Java (11)
6-
* AWS Lambda, DynamoDB, API GW, SSM
6+
* AWS Lambda, DynamoDB, API GateWay, SNS, using the [AWS SDK for Java v2.x](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/home.html)
77
* Serverless.com
88

99
This project aims to show how to deploy a basic API using AWS serverless services, and [Serverless Framework](https://serverless.com) to deploy it.
@@ -25,6 +25,18 @@ In order to do this tutorial, you need to install a few things:
2525

2626
## The Project
2727

28-
TODO: notes on expenser project
28+
A basic API for tracking expenses.
2929

30-
TODO: tut steps - gradle lib versions, etc etc
30+
* We will start with an API that allows to retrieve, create, update and delete expenses.
31+
* We will then create a second service that listens to these expense events, and keep a list of expense totals per person.
32+
33+
### Iterations
34+
35+
1. Define some domain classes with tests
36+
2. Create a simple AWS Lambda function that returns mocked expense data
37+
1. Implement a simple way of testing the lambda function
38+
3. Add an AWS API Gateway endpoint to call the Lambda function and test that via Postman
39+
4. Create a new API endpoint with Lambda function for creating & updating expenses
40+
5. Persist the expenses to DynamoDB and change Lambda to use the persisted data
41+
6. Create a Lambda function that listens to expense events via AWS Simple Notification Service and keep track of expense totals per person - show how it behaves via AWS Cloudwatch
42+
7. (if time) hook up API Gateway endpoint to expense totals lambda

aws-sdk-2/expenses-1/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Java AWS Lambda with Serverless.com Tutorial
2+
3+
## Expense Service Tutorial - Iteration 1
4+
5+
Goal: Define core domain classes
6+
7+
Steps
8+
1. Implement `Expense`
9+
2. Implement `Person`
10+
3. TODO: other bussiness logic container/"service" class? "Repository" with mocked implementation...
11+
4. Test!

aws-sdk-2/expenses-1/build.gradle

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apply plugin: 'java'
2+
3+
repositories {
4+
mavenCentral()
5+
}
6+
7+
sourceCompatibility = 1.11
8+
targetCompatibility = 1.11
9+
10+
dependencies {
11+
// compile (
12+
// 'com.amazonaws:aws-lambda-java-core:1.1.0',
13+
// 'com.amazonaws:aws-lambda-java-log4j:1.0.0',
14+
// 'com.amazonaws:aws-lambda-java-events:2.2.6',
15+
// 'com.fasterxml.jackson.core:jackson-core:2.8.5',
16+
// 'com.fasterxml.jackson.core:jackson-databind:2.8.5',
17+
// 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
18+
// )
19+
20+
testImplementation(
21+
'org.junit.jupiter:junit-jupiter-api:5.1.0'
22+
)
23+
testRuntimeOnly(
24+
'org.junit.jupiter:junit-jupiter-engine:5.1.0'
25+
)
26+
}
27+
28+
test {
29+
// environment "STAGE","development"
30+
useJUnitPlatform()
31+
}
32+
33+
// Task for building the zip file for upload
34+
task buildZip(type: Zip) {
35+
// Using the Zip API from gradle to build a zip file of all the dependencies
36+
//
37+
// The path to this zip file can be set in the serverless.yml file for the
38+
// package/artifact setting for deployment to the S3 bucket
39+
//
40+
// Link: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Zip.html
41+
42+
// set the base name of the zip file
43+
baseName = "expenses-service"
44+
from compileJava
45+
from processResources
46+
into('lib') {
47+
from configurations.runtime
48+
}
49+
}
50+
51+
build.dependsOn buildZip
52+

aws-sdk-2/expenses-2/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Java AWS Lambda with Serverless.com Tutorial
2+
3+
## Expense Service Tutorial - Iteration 2
4+
5+
Goal: Implement a basic AWS Lambda function that returns mocked expense data.
6+
7+
TODO: for dependencies see: https://mvnrepository.com/artifact/software.amazon.awssdk/bom/2.17.146
8+
* using BOM vs individual SDK libs
9+
10+
Steps:
11+
1. Create `serverless.yml`
12+
2. `maven` vs `gradle` file
13+
3. Implement Lambda handler
14+
4. Implement a simple way of testing lambda

aws-sdk-2/expenses-2/build.gradle

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apply plugin: 'java'
2+
3+
repositories {
4+
mavenCentral()
5+
}
6+
7+
sourceCompatibility = 1.11
8+
targetCompatibility = 1.11
9+
10+
dependencies {
11+
compile (
12+
'org.apache.logging.log4j:log4j-api:2.17.2',
13+
'org.apache.logging.log4j:log4j-core:2.17.2',
14+
'com.fasterxml.jackson.core:jackson-core:2.13.1',
15+
'com.fasterxml.jackson.core:jackson-databind:2.13.1',
16+
'com.fasterxml.jackson.core:jackson-annotations:2.13.1'
17+
)
18+
19+
testImplementation(
20+
'org.junit.jupiter:junit-jupiter-api:5.8.2'
21+
)
22+
testRuntimeOnly(
23+
'org.junit.jupiter:junit-jupiter-engine:5.8.2'
24+
)
25+
}
26+
27+
test {
28+
environment "STAGE","development"
29+
useJUnitPlatform()
30+
}
31+
32+
// Task for building the zip file for upload
33+
task buildZip(type: Zip) {
34+
// Using the Zip API from gradle to build a zip file of all the dependencies
35+
//
36+
// The path to this zip file can be set in the serverless.yml file for the
37+
// package/artifact setting for deployment to the S3 bucket
38+
//
39+
// Link: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Zip.html
40+
41+
// set the base name of the zip file
42+
baseName = "expenses-service"
43+
from compileJava
44+
from processResources
45+
into('lib') {
46+
from configurations.runtime
47+
}
48+
}
49+
50+
build.dependsOn buildZip
51+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*.class
2+
.gradle
3+
/build/
4+
/bin/
5+
/.settings/
6+
.project
7+
.classpath
8+
9+
# Package Files
10+
*.jar
11+
*.war
12+
*.ear
13+
14+
# Serverless directories
15+
.serverless
16+
17+
!/gradle/wrapper/gradle-wrapper.jar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id 'java-library'
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
sourceCompatibility = 1.8
10+
targetCompatibility = 1.8
11+
12+
dependencies {
13+
api (
14+
'com.amazonaws:aws-lambda-java-core:1.2.1',
15+
'com.amazonaws:aws-lambda-java-log4j:1.0.1',
16+
'com.fasterxml.jackson.core:jackson-core:2.11.0',
17+
'com.fasterxml.jackson.core:jackson-databind:2.11.0',
18+
'com.fasterxml.jackson.core:jackson-annotations:2.11.0'
19+
)
20+
}
21+
22+
// Task for building the zip file for upload
23+
task buildZip(type: Zip) {
24+
// Using the Zip API from gradle to build a zip file of all the dependencies
25+
//
26+
// The path to this zip file can be set in the serverless.yml file for the
27+
// package/artifact setting for deployment to the S3 bucket
28+
//
29+
// Link: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Zip.html
30+
31+
// set the base name of the zip file
32+
archiveBaseName = "hello"
33+
from compileJava
34+
from processResources
35+
into('lib') {
36+
from configurations.runtimeClasspath
37+
}
38+
}
39+
40+
build.dependsOn buildZip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)