v2 Plugin System: lambda-init, lambda-build, lambda-deploy#567
Merged
Conversation
…6 from CryptoSwift
Collaborator
Author
|
Issue tracker #566 |
|
Could we add the ability to pass build options. Sometimes it is nice to optimize for size and we can use |
d419e52 to
9207246
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces the v2 SwiftPM plugin system for the Swift AWS Lambda Runtime by splitting the legacy archive workflow into three focused commands (lambda-init, lambda-build, lambda-deploy) backed by a shared AWSLambdaPluginHelper executable, and updates docs/examples/CI accordingly.
Changes:
- Add
AWSLambdaPluginHelperexecutable and new SwiftPM command plugins (lambda-init,lambda-build,lambda-deploy), keepingarchiveas a deprecated passthrough. - Add generated lightweight AWS service clients (Lambda/IAM/S3/STS) plus new argument-parsing tests and an end-to-end integration script.
- Refresh DocC + README + examples + CI workflows to use the new plugin commands and Amazon Linux 2023 defaults.
Reviewed changes
Copilot reviewed 74 out of 75 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/AWSLambdaPluginHelperTests/Placeholder.swift | Keeps test target valid |
| Tests/AWSLambdaPluginHelperTests/DeployerS3Tests.swift | S3/deploy parsing tests |
| Tests/AWSLambdaPluginHelperTests/DeployerConfigurationTests.swift | Deployer CLI parsing tests |
| Tests/AWSLambdaPluginHelperTests/BuilderConfigurationTests.swift | Builder CLI parsing tests |
| Sources/AWSLambdaRuntime/Docs.docc/tutorials/04-deploy-function.tutorial | Tutorial updated for AL2023 + lambda-build |
| Sources/AWSLambdaRuntime/Docs.docc/tutorials/03-write-function.tutorial | Tutorial text updated for AL2023 |
| Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-04-plugin-archive.sh | Doc snippet updated to lambda-build |
| Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-03-plugin-archive.sh | Doc snippet updated to lambda-build |
| Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-02-plugin-archive.sh | Doc snippet updated to lambda-build |
| Sources/AWSLambdaRuntime/Docs.docc/quick-setup.md | Quick setup updated to lambda-build/lambda-deploy |
| Sources/AWSLambdaRuntime/Docs.docc/Deployment.md | Deployment guide updated for lambda-deploy |
| Sources/AWSLambdaPluginHelper/Process.swift | New process execution + output capture |
| Sources/AWSLambdaPluginHelper/lambda-init/Template.swift | Scaffold templates for init |
| Sources/AWSLambdaPluginHelper/lambda-init/Initializer.swift | Scaffold logic + entrypoint detection |
| Sources/AWSLambdaPluginHelper/GeneratedClients/STS/STSShapes.swift | Generated STS shapes |
| Sources/AWSLambdaPluginHelper/GeneratedClients/STS/STSErrors.swift | Generated STS errors |
| Sources/AWSLambdaPluginHelper/GeneratedClients/STS/STSClient.swift | Generated STS client |
| Sources/AWSLambdaPluginHelper/GeneratedClients/S3/S3Shapes.swift | Generated S3 shapes |
| Sources/AWSLambdaPluginHelper/GeneratedClients/S3/S3Errors.swift | Generated S3 errors |
| Sources/AWSLambdaPluginHelper/GeneratedClients/S3/S3Client.swift | Generated S3 client |
| Sources/AWSLambdaPluginHelper/GeneratedClients/Lambda/LambdaShapes.swift | Generated Lambda shapes |
| Sources/AWSLambdaPluginHelper/GeneratedClients/Lambda/LambdaErrors.swift | Generated Lambda errors |
| Sources/AWSLambdaPluginHelper/GeneratedClients/Lambda/LambdaClient.swift | Generated Lambda client |
| Sources/AWSLambdaPluginHelper/GeneratedClients/IAM/IAMShapes.swift | Generated IAM shapes |
| Sources/AWSLambdaPluginHelper/GeneratedClients/IAM/IAMErrors.swift | Generated IAM errors |
| Sources/AWSLambdaPluginHelper/GeneratedClients/IAM/IAMClient.swift | Generated IAM client |
| Sources/AWSLambdaPluginHelper/Extensions.swift | Data/String helpers |
| Sources/AWSLambdaPluginHelper/AWSLambdaPluginHelper.swift | Helper command dispatch |
| Sources/AWSLambdaPluginHelper/ArgumentExtractor.swift | CLI argument extraction helper |
| scripts/integration-test.sh | End-to-end plugin integration test |
| scripts/generate-aws-clients.sh | Maintainer client generation script |
| readme.md | Top-level README updated to new plugins |
| Plugins/Documentation.docc/Proposals/0001-v2-plugins.md | Proposal doc updates |
| Plugins/AWSLambdaPackager/PluginUtils.swift | Guard legacy plugin utils by swift version |
| Plugins/AWSLambdaPackager/Plugin@swift-6.4.swift | archive passthrough to helper (6.4+) |
| Plugins/AWSLambdaPackager/Plugin.swift | archive implementation (swift < 6.4) |
| Plugins/AWSLambdaInitializer/Plugin.swift | lambda-init SwiftPM plugin |
| Plugins/AWSLambdaDeployer/Plugin.swift | lambda-deploy SwiftPM plugin |
| Plugins/AWSLambdaBuilder/Plugin.swift | lambda-build SwiftPM plugin |
| Package@swift-6.4.swift | Swift 6.4 manifest gating new plugins |
| Package.swift | Dependency version bumps |
| Examples/Streaming+FunctionUrl/README.md | Example updated to new plugins |
| Examples/Streaming+Codable/README.md | Example updated to new plugins |
| Examples/Streaming+APIGateway/README.md | Example updated to new plugins |
| Examples/ServiceLifecycle+Postgres/README.md | Example updated to new plugins |
| Examples/S3EventNotifier/README.md | Example updated to new plugins |
| Examples/S3_Soto/README.md | Example updated to new plugins |
| Examples/S3_AWSSDK/README.md | Example updated to new plugins |
| Examples/ResourcesPackaging/README.md | Example updated to new plugins |
| Examples/README.md | Examples index updated (docker/container + aws configure) |
| Examples/MultiTenant/README.md | Example updated to new plugins |
| Examples/MultiSourceAPI/README.md | Example updated to new plugins |
| Examples/ManagedInstances/README.md | Example updated to new plugins |
| Examples/JSONLogging/README.md | Example updated to new plugins |
| Examples/HummingbirdLambda/README.md | Example updated to new plugins |
| Examples/HelloWorldNoTraits/README.md | Example updated to new plugins |
| Examples/HelloWorld/README.md | Example updated to new plugins |
| Examples/HelloJSON/README.md | Example updated to new plugins |
| Examples/CDK/README.md | Example updated to new plugins |
| Examples/BackgroundTasks/README.md | Example updated to new plugins |
| Examples/APIGatewayV2+LambdaAuthorizer/README.md | Example updated to new plugins |
| Examples/APIGatewayV2/README.md | Example updated to new plugins |
| Examples/APIGatewayV1/README.md | Example updated to new plugins |
| Examples/_MyFirstFunction/create_function.sh | Script updated for new flow |
| Examples/_MyFirstFunction/create_and_deploy_function.sh | Legacy script removed |
| Examples/_MyFirstFunction/clean.sh | Cleanup script updated to lambda-deploy --delete |
| .swiftformatignore | swiftformat ignore updates |
| .licenseignore | License ignore updates |
| .gitignore | Ignore .kiro/.claude, etc. |
| .github/workflows/scripts/check-archive-plugin-swift64.sh | New Swift 6.4 packaging test |
| .github/workflows/pull_request.yml | CI adjustments (docs check disabled, swift64 packaging test) |
| .github/workflows/integration_tests.yml | Add Swift 6.4 packaging plugin job |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The label still used the legacy plugin name; align it with the helper for clearer debugging/log correlation. Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Previously a failed template write was printed but swallowed, so the SwiftPM plugin exited 0 and could not detect that scaffolding failed. Re-throw so the failure surfaces as a non-zero exit. Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The function re-read CommandLine.arguments instead of using its arguments parameter, contradicting its signature and hurting testability. Use the parameter. Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
URL(string:) is for URLs, not filesystem paths, and can mis-handle absolute paths containing spaces. Use URL(fileURLWithPath:). Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
URL(string:) is for URLs, not filesystem paths, and can mis-handle absolute paths containing spaces. Use URL(fileURLWithPath:). Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The lambda-init plugin's command type was named AWSLambdaPackager (copy-paste leftover). Rename it to match the plugin so diagnostics and stack traces are unambiguous. Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The lambda-build plugin's command type was named AWSLambdaPackager (copy-paste leftover). Rename it to match the plugin. The default output directory is derived from the type name, so it moves from outputs/AWSLambdaPackager to outputs/AWSLambdaBuilder; update the Swift 6.4 archive-plugin CI script accordingly. Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sed -i '' is BSD/macOS-specific and fails on GNU sed (Linux). Use sed -i.bak, which works on both, and remove the backup file afterward. Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The ignore entry pointed at Plugins/AWSLambdaInitializer/Template.swift, which does not exist. The scaffold template lives at Sources/AWSLambdaPluginHelper/lambda-init/Template.swift; point the ignore there. Addresses Copilot review comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Renaming the lambda-build plugin type to AWSLambdaBuilder (Copilot review) changed its default output directory from .build/plugins/AWSLambdaBuilder/outputs/AWSLambdaPackager to .build/plugins/AWSLambdaBuilder/outputs/AWSLambdaBuilder. Update every lambda-build reference to match: - Deployer.swift: the default builderPath lookup (the legacy archive packagerPath fallback is left pointing at AWSLambdaPackager). - All example READMEs, SAM templates, CDK stack, and DocC docs/tutorials. The archive-verb references (check-archive-plugin.sh, the archive path in the Swift 6.4 CI script, and the Deployer legacy fallback) intentionally keep the AWSLambdaPackager/AWSLambdaPackager path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR delivers the v2 plugin system, replacing the legacy single-purpose
archiveplugin with three focused SwiftPM command plugins that cover the end-to-end developer experience:lambda-init— Scaffold a new Lambda function from a templatelambda-build— Compile and package for Amazon Linux 2023 (via Docker or Apple container)lambda-deploy— Deploy to AWS Lambda (create, update, or delete)The legacy
archivecommand is preserved as a deprecated passthrough tolambda-build.Quick Start
Key Changes
Architecture
AWSLambdaPluginHelperexecutableInitializer,Builder, orDeployerbased onargv[1]Builder (
lambda-build)amazonlinux2toamazonlinux2023--cross-compileoption (replaces--container-cli):docker,container,swift-static-sdk,custom-sdk-Xlinker -sand--no-stripopt-out--output-directoryaccepted as deprecated alias for--output-pathDeployer (
lambda-deploy)AWSLambdaBasicExecutionRoleFunctionURLRequestusage in source code to enable URL without explicit--with-urlInitializer (
lambda-init)Sources/main.swiftandSources/<Name>/<Name>.swift)Dependencies
soto-corefor AWS credential management, SigV4 signing, and HTTP transportVendored/Backward Compatibility
swift package archivepreserved as deprecated alias (emits warning, delegates tolambda-build)--container-cliaccepted as deprecated alias for--cross-compile--output-directoryaccepted as deprecated alias for--output-patharchiveCLI options continue to workDocumentation
Known Limitations
--build-system native. On Swift 6.4 the new default build system (Swift Build) fails to statically linkAWSLambdaPluginHelper: SotoCore transitively pulls in two vendored BoringSSL copies (swift-crypto'sCCryptoBoringSSLand swift-nio-ssl'sCNIOBoringSSL), and Swift Build emits duplicate C++ symbols at link time. The legacy build system links the same package cleanly, so the CI static build is pinned to--build-system nativeuntil the upstream issue is fixed: Swift Build 6.4: duplicate libc++abi symbols when statically linking two C++ targets swiftlang/swift-package-manager#10237.nightly-main(6.5-dev) Linux job is expected to fail. The 6.5-dev compiler crashes while compilingAWSLambdaRuntimeTests(a SIL verification error in theOwnershipModelEliminatorpass on aMutexcaptured by a nestedTaskinside a task group). This is a toolchain bug, not a problem in this PR: the same code compiles on 6.1 through 6.4. Reported upstream with a minimal reproducer: Compiler crash on main (6.5-dev): SIL verification error (debug_value undef) on Mutex captured in nested Task inside task group swiftlang/swift#90211.nightly-maintracks an unreleased toolchain and is not a release target, so we are not working around it here.docs_check_enabled: false). A regression inswiftlang/github-workflows(fix concurrency api usage #282) passes the.spi.ymldocumentation target to--targetwith literal quotes, so the check fails withno target named '"AWSLambdaRuntime"'. Pinning the workflow version does not help because the reusable workflow always fetches itscheck-docs.shfrommain. Re-enable once the upstream fix lands: Update dock check syntax issue swiftlang/github-workflows#290 (tracked in docs-check broken by #282: quoted doc target + docs_check_targets input ignored in containers swiftlang/github-workflows#291).The SotoCore
LoginCredentialProvidertoken-persistence issue in the SwiftPM sandbox is now resolved upstream (soto-core#692, released in soto-core 7.14.0), and this PR already requiresfrom: "7.14.0".Testing
scripts/integration-test.sh)