Skip to content

Add versioned Lambda asset uploads#6859

Draft
iloewensen wants to merge 1 commit intoanomalyco:devfrom
iloewensen:lambda-asset-versioning
Draft

Add versioned Lambda asset uploads#6859
iloewensen wants to merge 1 commit intoanomalyco:devfrom
iloewensen:lambda-asset-versioning

Conversation

@iloewensen
Copy link
Copy Markdown

@iloewensen iloewensen commented May 6, 2026

Summary

Adds an opt-in Lambda code asset path controlled by SST_LAMBDA_CODE_ASSET_VERSIONING.

When enabled, SST uploads Lambda zip assets to a stable S3 key and updates the existing BucketObjectv2 using sourceHash. Lambda functions then reference the uploaded object version through s3ObjectVersion.

Motivation

Large deployments with many Lambda functions currently create a new S3 object key for every function code change. In testing with 250 functions, this caused significant S3 object churn and larger Pulumi state updates.

Measured results from the investigation:

  • Current behavior, 250 functions: ~4m22s
  • Versioned Lambda assets, 250 functions: ~2m43s
  • No code changes: ~13s

CloudTrail and Pulumi debug logs did not show AWS throttling as the primary bottleneck. The remaining cost appears to be Lambda control-plane update latency across many functions.

Changes

  • Adds SST_LAMBDA_CODE_ASSET_VERSIONING=1 / true.
  • Uses stable Lambda asset keys under lambda/<app>/<stage>/<function>/code.zip.
  • Sets sourceHash on the BucketObjectv2 so Pulumi updates the same object when code changes.
  • Passes s3ObjectVersion to Lambda so code updates point at the exact uploaded object version.
  • Enables versioning on the SST asset bucket during AWS bootstrap.
  • Adds lifecycle rules to keep Lambda asset versions bounded.

Compatibility

Default behavior is unchanged when SST_LAMBDA_CODE_ASSET_VERSIONING is not set.

Dev bridge code keeps the existing hashed assets/dev-bridge-code-<hash>.zip behavior.

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.

1 participant