Skip to content

AWS Lambda .NET 10 Deployment

Overview

AWS Lambda supports .NET 10 as a managed runtime (dotnet10) since January 2026. This document explains the deployment architecture for the S3 Notifier Lambda function.

AWS Lambda .NET Runtime Support

Runtime .NET Version Status Deprecation
dotnet10 .NET 10 Current Nov 14, 2028
dotnet8 .NET 8 Available Nov 10, 2026
dotnet6 .NET 6 Deprecated Past EOL

Sources:

Current Configuration

Project Configuration

<!-- src/services/s3-notifier/SyRF.S3FileSavedNotifier.Endpoint/SyRF.S3FileSavedNotifier.Endpoint.csproj -->
<PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <AWSProjectType>Lambda</AWSProjectType>
</PropertyGroup>

Terraform Configuration

# camarades-infrastructure/terraform/lambda/main.tf
resource "aws_lambda_function" "s3_notifier_production" {
  function_name = "syrfAppUploadS3Notifier"
  runtime       = "dotnet10"
  handler       = "SyRF.S3FileSavedNotifier.Endpoint::SyRF.S3FileSavedNotifier.Endpoint.S3FileReceivedHandler::HandleEvent"
  # ...
}

CI/CD Build Command

# Using AWS Lambda dotnet10 managed runtime
# -r linux-x64: Target Linux (Lambda's OS)
# --self-contained false: Use managed runtime (smaller package)
dotnet publish -c Release -r linux-x64 --self-contained false -o publish

Deployment Process

  1. Build: CI/CD runs dotnet publish to create deployment package
  2. Package: Files are zipped into production.zip (~15MB compressed, ~44MB uncompressed)
  3. Upload: Package uploaded to S3 (lambda-packages/production.zip)
  4. Deploy: Terraform updates Lambda function with new package

Benefits of Managed Runtime

Aspect Managed Runtime Self-Contained (previous)
Package Size ~15MB compressed ~25MB compressed (with bundled runtime)
Cold Start Faster Slower (bundled runtime to load)
Maintenance AWS-managed runtime updates Manual runtime updates
Build Time Faster Slower (R2R compilation)

Note: Package sizes are larger than typical Lambda functions because this service includes many dependencies (MassTransit, MongoDB driver, Elastic APM, AWS SDK, etc.).

Handler Configuration

The Lambda function uses a class-based handler:

// S3FileReceivedHandler.cs
public class S3FileReceivedHandler
{
    [LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
    public async Task HandleEvent(S3EventNotification input, ILambdaContext context)
    {
        // Process S3 events
    }
}

The handler is specified in Terraform as:

SyRF.S3FileSavedNotifier.Endpoint::SyRF.S3FileSavedNotifier.Endpoint.S3FileReceivedHandler::HandleEvent

Format: {Assembly}::{Namespace.Class}::{Method}

Required NuGet Packages

<ItemGroup>
    <PackageReference Include="Amazon.Lambda.Core" Version="2.5.0" />
    <PackageReference Include="Amazon.Lambda.S3Events" Version="3.1.0" />
    <PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" />
    <PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.11.0" />
</ItemGroup>

Monitoring

CloudWatch Metrics

  • Duration: Function execution time
  • Init Duration: Cold start initialization time
  • Memory Used: Memory consumption during execution
  • Invocations: Number of function calls
  • Errors: Failed invocations

Logs

Function logs are written to CloudWatch Logs group: /aws/lambda/syrfAppUploadS3Notifier

Rollback

If issues occur, you can rollback by:

  1. Download previous package from GitHub Releases
  2. Upload to S3 (lambda-packages/production.zip)
  3. Run Terraform to update the Lambda function

Or revert to a previous git commit and re-run CI/CD.

Historical Note: Self-Contained Deployment

Prior to January 2026, AWS Lambda did not have a dotnet10 managed runtime. During that period, we used a self-contained deployment approach that bundled the .NET 10 runtime with the Lambda function. This is no longer needed since AWS now provides the dotnet10 managed runtime.

The self-contained approach required:

  • <AssemblyName>bootstrap</AssemblyName> in .csproj
  • --self-contained true -r linux-x64 build flags
  • runtime = "provided.al2023" in Terraform
  • Custom bootstrap implementation in Program.cs

These configurations have been removed/simplified now that the managed runtime is available.