[plugin] Use Amazon Linux 2023 as default base image for Swift 6.3+#668
[plugin] Use Amazon Linux 2023 as default base image for Swift 6.3+#668sebsto wants to merge 4 commits into
Conversation
|
The swift-nightly-main failure is unrelated to this PR. It is caused by stricter region-isolation diagnostics in the nightly compiler hitting the current pinned version of swift-async-algorithms (MultiProducerSingleConsumerAsyncChannel+Internal.swift). See apple/swift-async-algorithms#418. |
|
Hey @MahdiBM Can you have a look and comment on this change ? |
25bfae1 to
6bbb23b
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Lambda packager to select Amazon Linux 2023 Swift Docker images by default for Swift 6.3+ while preserving Amazon Linux 2 for older Swift versions.
Changes:
- Adds Swift-version-based Amazon Linux image selection and verbose logging in the packager plugin.
- Bumps several package dependency minimum versions.
- Adds documentation for the ResourcesPackaging example and links it from the examples index.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
Plugins/AWSLambdaPackager/Plugin.swift |
Updates default Docker image selection and help text for Amazon Linux 2023/2. |
Package.swift |
Raises minimum versions for NIO, swift-log, swift-collections, and service-lifecycle. |
Examples/ResourcesPackaging/README.md |
Adds usage, deployment, invocation, and cleanup instructions for the resources packaging example. |
Examples/README.md |
Adds the ResourcesPackaging example to the examples list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Technically speaking, any app that runs on Swift 6.2 and below should also be able to run on Swift 6.3. So checking the Swift version is probably not very helpful. A swift version upgrade is supposed to always work out, although sometimes it can go wrong when the newer compiler comes with some issues or bugs. I'm only worried maybe some people are relying on the plugin using amazonlinux2 images. If that is a concern (e.g. if something breaks when you upload a amazonlinux2023 executable to a amazonlinux2 aws lambda) then the safest option would be to print a big scary warning by default and mention that they should pass some kind of flag to ensure they'll use amazon linux 2023 since amazon linux 2 is very outdated 🤔. So yeah. I'm not sure how gracefully AWS handles that. If things will be just fine, then we can take a bit of a risk and just get rid of amazon Linux 2. Otherwise the safer option is a big warning to ask users to manually choose amazonlinux2023 (--base-docker-image swift:amazonlinux2023 ?), IMO. |
|
Good points. Let me address them: On the Swift version check: You're right that a package targeting swift-tools-version 6.1 will compile fine with the Swift 6.3 compiler (source compatibility is forward). The On the real risk (build/deploy mismatch): The actual concern is not Swift version compatibility but OS-level library compatibility. So the build environment and the Lambda runtime must match. This was already the case before this PR (build on AL2 → deploy to On the approach: I think we can simplify: always default to This makes the migration explicit without being scary. Users who still need AL2 have a clear escape hatch. What do you think? |
|
So ... I think we should take the safer approach unless we can confirm just updating to al2023 will not cause issues for like more than ~1% of the users. The actual issue is that users will need to manually update to provided.al2023. So unless someone with deep knowledge/experience can come through and say the risk is very low, we should take the safer route IMO. In the future we can still change the default to 2023 if we ever think it's a safe default. |
|
Which then means we'll also have to update the docs and mention that they default al2 is only kept for legacy reasons and users should theoretically always pass that argument to make the plugin use al2023, if the machine they're building on is not already al2023. Also ... a question. Penny CI builds stuff in an amazonlinux2023 container. Shouldn't the plugin simply just use the environment instead of using the al2 default? |
|
Hello @MahdiBM The ABI compatibility is not in the discussion because the binaries are statically linked with all Swift libraries. The risk is about system libraries, such as libgc and the crypto ones. If I summarize your message, you're suggesting to have an Amazon Linux 2023 compilation as an opt-in flag to avoid breaking builds or deployments. I kind of agree with that suggestion. Let's bring in the wider community for discussion before taking a decision. |
Now that Docker Hub has official Swift images based on Amazon Linux 2023 (starting with 6.3), the packager plugin picks the right base image automatically depending on the Swift version:
swift:<version>-amazonlinux2023swift:<version>-amazonlinux2(unchanged behavior)amazonlinux2023When only a major version is provided (e.g.
--swift-version 6without a minor), we conservatively treat it as 6.0 and use Amazon Linux 2, since we can't be sure it's 6.3+.Also added a verbose log line showing the resolved Swift version, Amazon Linux version, and final base image to help with debugging.
The
--base-docker-imageflag still overrides everything as before.