Description
Expected behavior
When a Lambda executable is archived and the executable has Swift package dependencies that have their own resources, the executable will fail when the resources are accessed.
I discovered this issue with AWS SDK for Swift but I'd expect this crash will arise with any Lambda function dependency that accesses resources.
#333 copies resources to the archive for the executable's own resources, but it does not copy resources for the executable's dependencies. Perhaps copying all *.resources
bundles in the build products to the archive would solve this problem? Another alternative might be to use SPM artifacts or commands to exactly identify the relevant dependencies and only copy resources for those.
I'm willing to submit a pull request to fix this but before starting, I would appreciate opinions from others on how best to select the right dependency resource bundles for inclusion.
Actual behavior
Lambda is built and archived and uploaded to Lambda, then called with a request that causes the dependency to access its resources.
Here is the error message received for aws-sdk-swift as a dependency:
AWSClientRuntime/resource_bundle_accessor.swift:12: Fatal error: could not load resource bundle: from /var/task/aws-sdk-swift_AWSClientRuntime.resources or /workspace/.build/aarch64-unknown-linux-gnu/release/aws-sdk-swift_AWSClientRuntime.resources
Steps to reproduce
- Create a new Lambda function Swift package, and require this project plus https://github.com/awslabs/aws-sdk-swift as dependencies.
- In your Lambda body, perform an AWS operation on any AWS service.
- Archive your Lambda, upload it & execute.
If possible, minimal yet complete reproducer code (or URL to code)
Will provide a project on request
What version of this project (swift-aws-lambda-runtime
) are you using?
main
Swift version
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0
Darwin 6c7e67b7b9dc 23.6.0 Darwin Kernel Version 23.6.0: Wed Jul 31 20:48:52 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T6020 arm64
Amazon Linux 2 docker image version
6.0.0-amazonlinux2