Skip to content

Commit 9a44017

Browse files
authored
2025 updates
Updated in 2025 to include major updates, related to changes in dependencies since the book was published in 2020. These changes include: - Updating to use Java 21, and to use the AWS Lambda Java 21 runtime - Some minor code updates enabled by Java 21 updates vs. Java 8 - mostly just using the var keyword - Switching to AWS SDK V2, which has syntax changes for accessing all AWS services - Testing code updated and modified to use JUnit 5 and Mockito 5 - Various other other library updates The original code is available in the pre-2025-updates tag.
1 parent 34fb04d commit 9a44017

File tree

58 files changed

+1256
-452
lines changed

Some content is hidden

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

58 files changed

+1256
-452
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Integration Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
id-token: write # Required for OIDC
11+
contents: read
12+
13+
jobs:
14+
integration-test:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 60
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/setup-java@v4
22+
with:
23+
distribution: 'corretto'
24+
java-version: '21'
25+
cache: 'maven'
26+
27+
- uses: aws-actions/setup-sam@v2
28+
with:
29+
use-installer: true
30+
31+
- uses: aws-actions/configure-aws-credentials@v4
32+
with:
33+
role-to-assume: arn:aws:iam::397589511426:role/account-wide-resources-GithubActionsRole-1CAIKQPYM5WD3
34+
aws-region: us-east-1
35+
36+
- run: ./deploy-all.sh
37+
working-directory: ./test-harness
38+
39+
- run: ./test-all.sh
40+
working-directory: ./test-harness
41+
42+
- if: always()
43+
run: ./teardown-all.sh
44+
working-directory: ./test-harness

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ For more info on the book itself, see:
1010
* [O'Reilly's Page](http://shop.oreilly.com/product/0636920178101.do)
1111
* [The book on Amazon](https://www.amazon.com/Programming-AWS-Lambda-Serverless-Applications/dp/149204105X)
1212

13+
## 2025 updates
14+
15+
This current branch of the code was updated in 2025 to include major updates, related to changes in
16+
dependencies since the book was published in 2020. These changes include:
17+
18+
* Updating to use Java 21, and to use the AWS Lambda Java 21 runtime
19+
* Some minor code updates enabled by Java 21 updates vs. Java 8 - mostly just using the `var` keyword
20+
* Switching to AWS SDK V2, which has syntax changes for accessing all AWS services
21+
* Testing code updated and modified to use JUnit 5 and Mockito 5
22+
* Various other other library updates
23+
24+
The original code is available in the [pre-2025-updates tag](https://github.com/symphoniacloud/programming-aws-lambda-book/releases/tag/pre-2025-updates).
25+
26+
## Miscellaneous other changes
27+
1328
For errata and updates, please see [this page](ErrataAndUpdates.md).
1429

1530
We plan on adding blog entries too - keep your eyes peeled on [our blog](https://blog.symphonia.io/) and [our Twitter](https://twitter.com/symphoniacloud).

chapter2/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
<version>1.0-SNAPSHOT</version>
1111

1212
<properties>
13-
<maven.compiler.source>1.8</maven.compiler.source>
14-
<maven.compiler.target>1.8</maven.compiler.target>
13+
<maven.compiler.release>21</maven.compiler.release>
1514
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1615
</properties>
1716

1817
<build>
1918
<plugins>
2019
<plugin>
20+
<groupId>org.apache.maven.plugins</groupId>
2121
<artifactId>maven-shade-plugin</artifactId>
22-
<version>3.2.1</version>
22+
<version>3.6.1</version>
2323
<executions>
2424
<execution>
2525
<phase>package</phase>

chapter2/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Resources:
77
HelloWorldLambda:
88
Type: AWS::Serverless::Function
99
Properties:
10-
Runtime: java8
10+
Runtime: java21
1111
MemorySize: 512
1212
Handler: book.HelloWorld::handler
1313
CodeUri: target/lambda.jar

chapter3/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
<version>1.0-SNAPSHOT</version>
1111

1212
<properties>
13-
<maven.compiler.source>1.8</maven.compiler.source>
14-
<maven.compiler.target>1.8</maven.compiler.target>
13+
<maven.compiler.release>21</maven.compiler.release>
1514
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1615
</properties>
1716

1817
<build>
1918
<plugins>
2019
<plugin>
20+
<groupId>org.apache.maven.plugins</groupId>
2121
<artifactId>maven-shade-plugin</artifactId>
22-
<version>3.2.1</version>
22+
<version>3.6.1</version>
2323
<executions>
2424
<execution>
2525
<phase>package</phase>
@@ -39,7 +39,7 @@
3939
<dependency>
4040
<groupId>com.amazonaws</groupId>
4141
<artifactId>aws-lambda-java-core</artifactId>
42-
<version>1.2.0</version>
42+
<version>1.4.0</version>
4343
<scope>provided</scope>
4444
</dependency>
4545
</dependencies>

chapter3/src/main/java/book/ContextLambda.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public class ContextLambda {
99
public Map<String, Object> handler(Object input, Context context) {
10-
Map<String, Object> toReturn = new HashMap<>();
10+
var toReturn = new HashMap<String, Object>();
1111
toReturn.put("getMemoryLimitInMB", context.getMemoryLimitInMB() + "");
1212
toReturn.put("getFunctionName", context.getFunctionName());
1313
toReturn.put("getFunctionVersion", context.getFunctionVersion());

chapter3/src/main/java/book/EnvVarLambda.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class EnvVarLambda {
44
public void handler(Object event) {
5-
String databaseUrl = System.getenv("DATABASE_URL");
5+
var databaseUrl = System.getenv("DATABASE_URL");
66
if (databaseUrl == null || databaseUrl.isEmpty())
77
System.out.println("DATABASE_URL is not set");
88
else

chapter3/src/main/java/book/ListMapLambda.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
public class ListMapLambda {
1010
public List<Integer> handlerList(List<Integer> input) {
11-
List<Integer> newList = new ArrayList<>();
11+
var newList = new ArrayList<Integer>();
1212
input.forEach(x -> newList.add(100 + x));
1313
return newList;
1414
}
1515

1616
public Map<String, String> handlerMap(Map<String, String> input) {
17-
Map<String, String> newMap = new HashMap<>();
17+
var newMap = new HashMap<String, String>();
1818
input.forEach((k, v) -> newMap.put("New Map -> " + k, v));
1919
return newMap;
2020
}
2121

2222
public Map<String, Map<String, Integer>> handlerNestedCollection(List<Map<String, Integer>> input) {
23-
Map<String, Map<String, Integer>> newMap = new HashMap<>();
23+
var newMap = new HashMap<String, Map<String, Integer>>();
2424
IntStream.range(0, input.size())
2525
.forEach(i -> newMap.put("Nested at position " + i, input.get(i)));
2626
return newMap;

chapter3/src/main/java/book/WhatIsMyLambdaEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class WhatIsMyLambdaEvent {
77
public void handler(InputStream is, OutputStream os) {
8-
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
8+
var s = new java.util.Scanner(is).useDelimiter("\\A");
99
System.out.println(s.hasNext() ? s.next() : "No input detected");
1010
}
1111
}

chapter3/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Resources:
99
Properties:
1010
FunctionName: HelloWorldJava
1111
Timeout: 2
12-
Runtime: java8
12+
Runtime: java21
1313
MemorySize: 512
1414
Handler: book.EnvVarLambda::handler
1515
CodeUri: target/lambda.jar

0 commit comments

Comments
 (0)