Skip to content

Lambda Worker Sample#152

Open
eamsden wants to merge 5 commits into
mainfrom
ea/aws-lambda
Open

Lambda Worker Sample#152
eamsden wants to merge 5 commits into
mainfrom
ea/aws-lambda

Conversation

@eamsden

@eamsden eamsden commented May 29, 2026

Copy link
Copy Markdown

Needs temporalio/sdk-dotnet#721

What was changed

Add sample code for a worker running on AWS Lambda

Why?

SDK-level implementation of serverless workers on AWS Lambda

Checklist

  1. Closes

  2. How was this tested:

Deployed a Lambda worker and ran a workflow

  1. Any docs updates needed?

@eamsden eamsden changed the title Draft: Lambda Worker Sample Lambda Worker Sample May 29, 2026
Comment thread src/LambdaWorker/Function.cs Outdated
Comment thread src/LambdaWorker/Starter/Program.cs
@eamsden
eamsden marked this pull request as ready for review June 16, 2026 22:53
@eamsden
eamsden requested a review from a team as a code owner June 16, 2026 22:53
@jmaeagle99 jmaeagle99 self-assigned this Jul 13, 2026
@@ -0,0 +1,299 @@
# Lambda Worker

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No best place to put this comment... I think the structure of this sample can be improved. As it is, looking at the source, it just looks like a pile of commingled files. Take a look at https://github.com/temporalio/samples-dotnet/tree/main/src/Encryption as an example of clean separation. Maybe the following structure:

  • Deploy (contains all of the scripts)
  • Starter (same as the current Starter directory)
  • Worker (all of the *.csproj and *.cs files for the worker, rename project file to have .Worker on end, remember to update deploy-lambda.sh with that change too, the compile exclusion in the csproj is removable)
  • README.md remains at the root
  • *.sample files remain at the root, but maybe rename to *.template.yaml if they are to be copy/pasted with substitutions.

Comment thread TemporalioSamples.sln
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemporalioSamples.EnvConfig", "src\EnvConfig\TemporalioSamples.EnvConfig.csproj", "{52CE80AF-09C3-4209-8A21-6CFFAA3B2B01}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemporalioSamples.LambdaWorker", "src\LambdaWorker\TemporalioSamples.LambdaWorker.csproj", "{D1D6B7AD-0E12-4D8C-83BE-9CE3EB916DD7}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two projects should be grouped into a folder in this solution file, probably called LambdaWorker.

}

[Fact]
public void ConfigureWorkerOptions_UsesEnvironmentOverrides()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this test is actually testing anything about the sample itself. Feels like it's testing the product or even just the EnvironmentVariableScope behavior, which isn't used anywhere else other than this test) rather than demonstrating any correctness about the sample.

@@ -0,0 +1,52 @@
#!/bin/bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file have a .sh extension? Maybe also rename to enable-telemetry.sh, or something more indicative of what this file does?

--function-name "$FUNCTION_NAME" \
--timeout 60 \
--layers "$ADOT_LAYER_ARN" \
--environment "Variables={TEMPORAL_API_KEY=${TEMPORAL_API_KEY},SSL_CERT_FILE=/etc/pki/tls/certs/ca-bundle.crt,OPENTELEMETRY_COLLECTOR_CONFIG_URI=/var/task/otel-collector-config.yaml,TEMPORAL_TASK_QUEUE=${TASK_QUEUE},TEMPORAL_LAMBDA_WORKFLOW_ID_PREFIX=${WORKFLOW_ID_PREFIX},TEMPORAL_LAMBDA_DEPLOYMENT_NAME=${DEPLOYMENT_NAME},TEMPORAL_LAMBDA_BUILD_ID=${BUILD_ID}}" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that TEMPORAL_LAMBDA_WORKFLOW_ID_PREFIX is needed here since only the starter project consumes it.


```bash
TEMPORAL_CONFIG_FILE="$PWD/temporal.toml" \
mise exec dotnet@8 -- dotnet run \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why invoke via mise here and not for the dotnet publish call in the deploy-lambda.sh script? I think remove mise since it's not a prereq and doesn't add value here.

@@ -0,0 +1,25 @@
// @@@SNIPSTART dotnet-lambda-worker

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why snipsync here? I thought we were applying docs snipsync in temporalio/features? Which allows us to evolve the samples without breaking docs.

}
}
} No newline at end of file
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: undo unrelated change

}

[Fact]
public void ConfigureWorkerOptions_SetsExpectedWorkerRegistration()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also feels like testing SDK behavior rather than sample behavior. I would drop it.


## Files

| File | Description |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be drastically simplified with the directory refactor mentioned above. I don't know if you really need to call out each individual file either. Maybe with the refactor, just state what each directory contains in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants