Skip to content

Conversation

phipag
Copy link
Contributor

@phipag phipag commented Aug 27, 2025

Summary

This PR introduces GraalVM support for powertools-cloudformation.

  • Also adds a sam-graalvm example to the existing example (this time I did not duplicate the code)
    • Reason for adding example:
      • Requires non-trivial metadata for S3 client
      • We don't have any E2E tests for this module yet to validate behavior at runtime
  • Updates graalvm-build workflow to run conditionally on changed modules only to avoid wasting time and GH runner resources.
  • Improve GraalVM.md developer documentation with common issues found during refactoring of unit tests to achieve GraalVM compatibility

Testing

Deployed as native image and validated that it works correctly. See logs below on provided.al2023 runtime:

Logs
@timestamp @message
2025-08-27T14:50:39.608+02:00 INIT_START Runtime Version: provided:al2023.v107 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2025-08-27T14:50:40.432+02:00 START RequestId: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Version: $LATEST
2025-08-27T14:50:40.438+02:00 27 Aug 2025 12:50:40,438 [INFO] <> (main) helloworld.App:50: CloudFormationCustomResourceEvent(requestType=Create, serviceToken=arn:aws:lambda:us-east-1:XXXXXXXXXXXX:function:powertools-examples-cloudformat-HelloWorldFunction-XXXXXXXXXX, responseUrl=https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/[REDACTED_PRESIGNED_URL], stackId=arn:aws:cloudformation:us-east-1:XXXXXXXXXXXX:stack/example-stack-name/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, requestId=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, logicalResourceId=HelloWorldCustomResource, physicalResourceId=null, resourceType=AWS::CloudFormation::CustomResource, resourceProperties={ServiceToken=arn:aws:lambda:us-east-1:XXXXXXXXXXXX:function:powertools-examples-cloudformat-HelloWorldFunction-XXXXXXXXXX, BucketName=example-bucket-name}, oldResourceProperties=null)
2025-08-27T14:50:40.438+02:00 27 Aug 2025 12:50:40,438 [INFO] <> (main) helloworld.App:52: Bucket Name example-bucket-name
2025-08-27T14:50:40.768+02:00 27 Aug 2025 12:50:40,768 [INFO] <> (main) helloworld.App:169: HeadBucketResponse(BucketRegion=us-east-1, AccessPointAlias=false)
2025-08-27T14:50:40.768+02:00 27 Aug 2025 12:50:40,768 [INFO] <> (main) helloworld.App:170: Bucket Created example-bucket-name
2025-08-27T14:50:40.768+02:00 27 Aug 2025 12:50:40,768 [DEBUG] <> (main) software.amazon.lambda.powertools.cloudformation.AbstractCustomResourceHandler:73: Preparing to send response [Status = SUCCESS,NoEcho = false,PhysicalResourceId = example-bucket-name,JSON = null,Reason = null] to https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/[REDACTED_PRESIGNED_URL].
2025-08-27T14:50:40.805+02:00 27 Aug 2025 12:50:40,804 [DEBUG] <> (main) software.amazon.lambda.powertools.cloudformation.CloudFormationResponse:161: ResponseBody: ResponseBody{status='SUCCESS', reason='See the details in CloudWatch Log Stream: 2025/08/27/[$LATEST]XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', physicalResourceId='example-bucket-name', stackId='arn:aws:cloudformation:us-east-1:XXXXXXXXXXXX:stack/example-stack-name/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', requestId='XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', logicalResourceId='HelloWorldCustomResource', noEcho=false}
2025-08-27T14:50:40.894+02:00 END RequestId: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2025-08-27T14:50:40.894+02:00 REPORT RequestId: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Duration: 461.26 ms Billed Duration: 1285 ms Memory Size: 512 MB Max Memory Used: 130 MB Init Duration: 822.99 ms
2025-08-27T14:51:34.730+02:00 START RequestId: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Version: $LATEST
2025-08-27T14:51:34.731+02:00 27 Aug 2025 12:51:34,731 [INFO] <> (main) helloworld.App:123: CloudFormationCustomResourceEvent(requestType=Delete, serviceToken=arn:aws:lambda:us-east-1:XXXXXXXXXXXX:function:powertools-examples-cloudformat-HelloWorldFunction-XXXXXXXXXX, responseUrl=https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/[REDACTED_PRESIGNED_URL], stackId=arn:aws:cloudformation:us-east-1:XXXXXXXXXXXX:stack/example-stack-name/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, requestId=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, logicalResourceId=HelloWorldCustomResource, physicalResourceId=example-bucket-name, resourceType=AWS::CloudFormation::CustomResource, resourceProperties={ServiceToken=arn:aws:lambda:us-east-1:XXXXXXXXXXXX:function:powertools-examples-cloudformat-HelloWorldFunction-XXXXXXXXXX, BucketName=example-bucket-name}, oldResourceProperties=null)
2025-08-27T14:51:34.731+02:00 27 Aug 2025 12:51:34,731 [INFO] <> (main) helloworld.App:126: Bucket Name example-bucket-name
2025-08-27T14:51:34.998+02:00 27 Aug 2025 12:51:34,997 [INFO] <> (main) helloworld.App:133: Bucket Deleted example-bucket-name
2025-08-27T14:51:34.998+02:00 27 Aug 2025 12:51:34,998 [DEBUG] <> (main) software.amazon.lambda.powertools.cloudformation.AbstractCustomResourceHandler:73: Preparing to send response [Status = SUCCESS,NoEcho = false,PhysicalResourceId = example-bucket-name,JSON = null,Reason = null] to https://cloudformation-custom-resource-response-useast1.s3.amazonaws.com/[REDACTED_PRESIGNED_URL].
2025-08-27T14:51:34.998+02:00 27 Aug 2025 12:51:34,998 [DEBUG] <> (main) software.amazon.lambda.powertools.cloudformation.CloudFormationResponse:161: ResponseBody: ResponseBody{status='SUCCESS', reason='See the details in CloudWatch Log Stream: 2025/08/27/[$LATEST]XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', physicalResourceId='example-bucket-name', stackId='arn:aws:cloudformation:us-east-1:XXXXXXXXXXXX:stack/example-stack-name/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', requestId='XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', logicalResourceId='HelloWorldCustomResource', noEcho=false}
2025-08-27T14:51:35.045+02:00 END RequestId: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2025-08-27T14:51:35.045+02:00 REPORT RequestId: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Duration: 314.95 ms Billed Duration: 315 ms Memory Size: 512 MB Max Memory Used: 132 MB

Changes

Issue number: #1838


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

…patible with subclass mock maker and native mode.
@phipag
Copy link
Contributor Author

phipag commented Aug 27, 2025

GraalVM unit tests also pass:

 Test run finished after 61 ms
[        11 containers found      ]
[         0 containers skipped    ]
[        11 containers started    ]
[         0 containers aborted    ]
[        11 containers successful ]
[         0 containers failed     ]
[        52 tests found           ]
[         0 tests skipped         ]
[        52 tests started         ]
[         0 tests aborted         ]
[        52 tests successful      ]
[         0 tests failed          ]

Copy link

@phipag phipag merged commit 5810719 into main Aug 28, 2025
15 checks passed
@phipag phipag deleted the phipag/issue1838 branch August 28, 2025 17:18
@github-project-automation github-project-automation bot moved this from Pending review to Coming soon in Powertools for AWS Lambda (Java) Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Coming soon
Development

Successfully merging this pull request may close these issues.

feat(graalvm): GraalVM support for CFN Custom Resources utility
2 participants