You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- This has been [fixed](https://github.com/apache/logging-log4j2/discussions/2364#discussioncomment-8950077) in Log4j 2.24.x. PT has been updated to use this version of Log4j
58
58
59
+
3.**Test Class Organization**
60
+
-**Issue**: Anonymous inner classes and lambda expressions in Mockito matchers cause `NoSuchMethodError` in GraalVM native tests
61
+
-**Solution**:
62
+
- Extract static inner test classes to separate concrete classes in the same package as the class under test
63
+
- Replace lambda expressions in `ArgumentMatcher` with concrete implementations
64
+
- Use `mockito-subclass` dependency in GraalVM profiles
# Powertools for AWS Lambda (Java) - CloudFormation Custom Resource Example with SAM on GraalVM
2
+
3
+
This project contains an example of a Lambda function using the CloudFormation module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/custom_resources/).
4
+
5
+
In this example you pass in a bucket name as a parameter and upon CloudFormation events a call is made to a lambda. That lambda attempts to create the bucket on CREATE events, create a new bucket if the name changes with an UPDATE event and delete the bucket upon DELETE events.
6
+
7
+
Have a look at [App.java](../../src/main/java/helloworld/App.java) for the full details.
8
+
9
+
## Build the sample application
10
+
11
+
> [!NOTE]
12
+
> Building AWS Lambda packages on macOS (ARM64/Intel) for deployment on AWS Lambda (Linux x86_64 or ARM64) will result in incompatible binary dependencies that cause import errors at runtime.
13
+
14
+
Choose the appropriate build method based on your operating system:
15
+
16
+
### Build locally using Docker
17
+
18
+
Recommended for macOS and Windows users: Cross-compile using Docker to match target platform of Lambda:
sam build --use-container --build-image powertools-examples-cloudformation-sam-graalvm
24
+
```
25
+
26
+
**Note**: The Docker run command mounts your local Maven cache (`~/.m2`) and builds the native binary with SNAPSHOT support, then SAM packages the pre-built binary.
27
+
28
+
### Build on native OS
29
+
30
+
For Linux users with GraalVM installed:
31
+
32
+
```shell
33
+
export JAVA_HOME=<path to GraalVM>
34
+
cd ../..
35
+
mvn clean -Pnative-image package -DskipTests
36
+
cd infra/sam-graalvm
37
+
sam build
38
+
```
39
+
40
+
## Deploy the sample application
41
+
42
+
```shell
43
+
sam deploy --guided --parameter-overrides BucketNameParam=my-unique-bucket-2.3.0718
44
+
```
45
+
46
+
This sample is based on Serverless Application Model (SAM). To deploy it, check out the instructions for getting started with SAM in [the examples directory](../../../README.md)
47
+
48
+
## Test the application
49
+
50
+
The CloudFormation custom resource will be triggered automatically during stack deployment. You can monitor the Lambda function execution in CloudWatch Logs to see the custom resource handling CREATE, UPDATE, and DELETE events for the S3 bucket.
51
+
52
+
Check out [App.java](../../src/main/java/helloworld/App.java) to see how it works!
0 commit comments