Skip to content

Commit ecc20f0

Browse files
authored
AmazonLinux2023 is now the default (#675)
Starting June, 20 2026, Amazon Linux 2 has reached end of support life. The Swift Lambda Runtime plugins now use Amazon Linux 2023 for cross compiling code. > [!WARNING] > When you compile on Amazon Linux 2023, you must deploy on Amazon Linux 2023 too **When using the console** <img width="946" height="254" alt="image" src="https://github.com/user-attachments/assets/6289a194-348c-4d90-be24-df7cdfb7e8c3" /> **When using the AWS CLI** ```sh aws lambda create-function \ --function-name MySwiftFunction \ --runtime provided.al2023 \ --role "$role_arn" \ // replace with the IAM role ARN to pass to your function --handler bootstrap \ --architectures arm64 \ --zip-file "fileb://MySwiftFunction.zip" ``` **When using SAM** ```yaml Resources: APIGatewayLambda: Type: AWS::Serverless::Function Properties: CodeUri: APIGatewayLambda.zip Timeout: 60 Handler: swift.bootstrap # ignored by the Swift runtime Runtime: provided.al2023 MemorySize: 128 Architectures: - arm64 ``` **When using the AWS CDK** ```ts const lambdaFunction = new lambda.Function(this, 'SwiftLambdaFunction', { runtime: lambda.Runtime.PROVIDED_AL2023, architecture: lambda.Architecture.ARM_64, handler: 'bootstrap', code: lambda.Code.fromAsset('APIGatewayLambda.zip'), memorySize: 128, timeout: cdk.Duration.seconds(30), environment: { LOG_LEVEL: 'debug', }, }); ```
1 parent d6a7eef commit ecc20f0

5 files changed

Lines changed: 8 additions & 50 deletions

File tree

Examples/CDK/infra/lib/lambda-api-project-stack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class LambdaApiStack extends cdk.Stack {
2424

2525
// Create the Lambda function
2626
const lambdaFunction = new lambda.Function(this, 'SwiftLambdaFunction', {
27-
runtime: lambda.Runtime.PROVIDED_AL2,
27+
runtime: lambda.Runtime.PROVIDED_AL2023,
2828
architecture: lambda.Architecture.ARM_64,
2929
handler: 'bootstrap',
3030
code: lambda.Code.fromAsset('../.build/plugins/AWSLambdaBuilder/outputs/AWSLambdaBuilder/APIGatewayLambda/APIGatewayLambda.zip'),

Plugins/AWSLambdaBuilder/Plugin.swift

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ struct AWSLambdaBuilder: CommandPlugin {
7777
buildConfiguration = .release
7878
}
7979

80-
// TODO: When running on Amazon Linux 2, we have to build directly from the plugin
81-
// launch the build, then call the helper just for the ZIP part
82-
8380
let tool = try context.tool(named: "AWSLambdaPluginHelper")
8481
let args =
8582
[
@@ -109,47 +106,6 @@ struct AWSLambdaBuilder: CommandPlugin {
109106
Diagnostics.error("AWSLambdaPluginHelper invocation failed: \(problem)")
110107
}
111108
}
112-
113-
// TODO: When running on Amazon Linux 2, we have to build directly from the plugin
114-
// private func build(
115-
// packageIdentity: Package.ID,
116-
// products: [Product],
117-
// buildConfiguration: PackageManager.BuildConfiguration,
118-
// verboseLogging: Bool
119-
// ) throws -> [LambdaProduct: URL] {
120-
// print("-------------------------------------------------------------------------")
121-
// print("building \"\(packageIdentity)\"")
122-
// print("-------------------------------------------------------------------------")
123-
//
124-
// var results = [LambdaProduct: URL]()
125-
// for product in products {
126-
// print("building \"\(product.name)\"")
127-
// var parameters = PackageManager.BuildParameters()
128-
// parameters.configuration = buildConfiguration
129-
// parameters.otherSwiftcFlags = ["-static-stdlib"]
130-
// parameters.logging = verboseLogging ? .verbose : .concise
131-
//
132-
// let result = try packageManager.build(
133-
// .product(product.name),
134-
// parameters: parameters
135-
// )
136-
// guard let artifact = result.executableArtifact(for: product) else {
137-
// throw Errors.productExecutableNotFound(product.name)
138-
// }
139-
// results[.init(product)] = artifact.url
140-
// }
141-
// return results
142-
// }
143-
144-
// private func isAmazonLinux2() -> Bool {
145-
// if let data = FileManager.default.contents(atPath: "/etc/system-release"),
146-
// let release = String(data: data, encoding: .utf8)
147-
// {
148-
// return release.hasPrefix("Amazon Linux release 2")
149-
// } else {
150-
// return false
151-
// }
152-
// }
153109
}
154110

155111
private enum BuilderErrors: Error, CustomStringConvertible {

Plugins/AWSLambdaPackager/Plugin.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ struct AWSLambdaPackager: CommandPlugin {
388388
(default is latest)
389389
This parameter cannot be used when --base-docker-image is specified.
390390
--base-docker-image <name> The name of the base docker image to use for the build.
391-
(default: swift:<version>-amazonlinux2)
392-
Note: Amazon Linux 2023 will become the default after June 30, 2026.
391+
(default: swift:<version>-amazonlinux2023)
392+
Amazon Linux 2 is deprecated since June 30, 2026.
393393
Visit Docker Hub for all available swift tags:
394394
https://hub.docker.com/_/swift/tags?name=amazonlinux
395395
This parameter cannot be used when --swift-version is specified.
@@ -537,8 +537,9 @@ private struct Configuration: CustomStringConvertible {
537537

538538
let swiftVersion = swiftVersionArgument.first ?? .none // undefined version will yield the latest docker image
539539

540+
// default to Amazon Linux 2023 after 30 June 2026 (Amazon Linux 2 is deprecated)
540541
self.baseDockerImage =
541-
baseDockerImageArgument.first ?? "swift:\(swiftVersion.map { $0 + "-" } ?? "")amazonlinux2"
542+
baseDockerImageArgument.first ?? "swift:\(swiftVersion.map { $0 + "-" } ?? "")amazonlinux2023"
542543

543544
self.disableDockerImageUpdate = disableDockerImageUpdateArgument
544545
self.containerCLI = try ContainerCLI.parse(

Sources/AWSLambdaPluginHelper/lambda-build/Builder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ struct Builder {
382382
This parameter cannot be used when --base-docker-image is specified.
383383
--base-docker-image <name> The name of the base docker image to use for the build.
384384
(default: swift:<version>-amazonlinux2023)
385+
Amazon Linux 2 is deprecated since June 30, 2026.
385386
Visit Docker Hub for all available swift tags:
386387
https://hub.docker.com/_/swift/tags?name=amazonlinux
387388
This parameter cannot be used when --swift-version is specified.

Sources/AWSLambdaRuntime/Docs.docc/Deployment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Resources:
292292
CodeUri: .build/plugins/AWSLambdaBuilder/outputs/AWSLambdaBuilder/APIGatewayLambda/APIGatewayLambda.zip
293293
Timeout: 60
294294
Handler: swift.bootstrap # ignored by the Swift runtime
295-
Runtime: provided.al2
295+
Runtime: provided.al2023
296296
MemorySize: 128
297297
Architectures:
298298
- arm64
@@ -466,7 +466,7 @@ export class LambdaApiStack extends cdk.Stack {
466466
467467
// Create the Lambda function
468468
const lambdaFunction = new lambda.Function(this, 'SwiftLambdaFunction', {
469-
runtime: lambda.Runtime.PROVIDED_AL2,
469+
runtime: lambda.Runtime.PROVIDED_AL2023,
470470
architecture: lambda.Architecture.ARM_64,
471471
handler: 'bootstrap',
472472
code: lambda.Code.fromAsset('../.build/plugins/AWSLambdaBuilder/outputs/AWSLambdaBuilder/APIGatewayLambda/APIGatewayLambda.zip'),

0 commit comments

Comments
 (0)