Skip to content

feat(#1613, #1660): Lambda versions, aliases and GetFunctionConfiguration - #1702

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/v0134-lambda
Nov 25, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/v0134-lambda

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Part of #1613: the Lambda workstream (versions, aliases, GetFunctionConfiguration, qualified ARNs). Still open in #1613: reserved and provisioned concurrency and function URLs (filed as a v0.137.0 follow-up), and the other services' workstreams.
Part of #1660: item 2 (GetFunctionConfiguration) and item 4 (LastUpdateStatus) ship here. Items 1, 3, 5 and 6 (ESM tags, GetFunction tag gating, GetResources listing ESMs, role-assumability check) remain.

  • PublishVersion: stores an immutable snapshot of $LATEST at function_version:{acct}/{region}/{name}/{n}, numbered from a per-function counter that never reuses a number. Each version records a fingerprint of the code and configuration it came from. The fingerprint covers the S3 code location (bucket, key and object version), so moving to another object publishes a new version even when the package has no CodeSha256. A publish whose fingerprint matches the newest version answers that version again. A stale RevisionId is PreconditionFailedException/412, using the error's published description. A stale CodeSha256 is InvalidParameterValueException with substrate's own message. Publish: true on CreateFunction and UpdateFunctionCode is honoured. UpdateFunctionConfiguration changes $LATEST only.
  • ListVersionsByFunction: lists $LATEST, then the versions in numeric order. Pages through v0.133's page[T] via jsonNextToken; MaxItems must be 1–10000, responses are capped at the published 50, and the token is bound to the function.
  • Aliases: Create, Get, Update, Delete and List. Weights follow the developer guide's rules: at most one additional version, which is not the alias's own FunctionVersion; a weight from 0 to 1; no weighted alias on $LATEST; the same execution role on both versions; published versions only. DeleteAlias on a missing alias answers 204, because its page publishes no not-found error.
  • Deterministic weighted routing: four bytes from the request's IDMint, read as a fraction of 2^32, are compared with the weight. Replay therefore routes each invocation to the version it ran on. See docs/reference/lambda.md#versions-and-aliases.
  • Qualifiers: Qualifier or a qualified FunctionName works on GetFunction, GetFunctionConfiguration, Invoke (X-Amz-Executed-Version reports the version that ran), the three permission operations and DeleteFunction. Versions and aliases each have their own resource policy. PublishVersion, ListVersionsByFunction and the alias operations refuse a qualified FunctionName with InvalidParameterValueException.
  • Security:
    • Scope. lambdaCheckFunctionScope refuses a function outside the caller's account and Region:
      • Another account's function (full or partial ARN) is AccessDeniedException/403. It uses the "no resource-based policy allows" sentence already recorded for layers (Lambda: cross-account public layer semantics (ListLayerVersions denied, GetLayerVersion AccessDenied for unpublished) #1272).
      • A full ARN in another Region is ResourceNotFoundException/404, "Functions from '' are not reachable in this region ('')".
      • It covers every function-path operation, TagResource/UntagResource/ListTags, CreateEventSourceMapping and UpdateEventSourceMapping (which now honours FunctionName, re-pointing the mapping), and EventBridge Scheduler's CreateSchedule/UpdateSchedule for templated and aws-sdk:lambda:invoke targets.
      • Tag and Untag save under the function's own scope, so a foreign ARN can no longer copy a function into the caller's account.
      • A stored schedule that still names a foreign function records intent rather than invoking it.
      • Cross-account invoke through a resource policy is not modelled; that is lambda: cross-account invoke and calls through a function's resource policy #1710.
    • Qualifier authorization. A Qualifier parameter is authorized against the qualified ARN only for the operations that act on the version or alias it names: GetFunction, GetFunctionConfiguration, Invoke, DeleteFunction, AddPermission, RemovePermission and GetPolicy. On those, a Deny on function:fn:prod refuses both ?Qualifier=prod and fn:prod. Every other operation is authorized against the function, so ?Qualifier=x cannot step around a Deny on UpdateFunctionCode, UpdateFunctionConfiguration, PutFunctionEventInvokeConfig or GetFunctionCodeSigningConfig.
  • Internal invokes: SNS, S3 notifications, API Gateway proxy integrations, event source mappings and Step Functions tasks now send the whole function ARN in the invoke path, with any version or alias as Qualifier. Lambda therefore resolves the function the ARN names, or refuses one in another account, instead of invoking a same-named local function or a function named after the alias. s3ARNLastComponent is removed. EventBridge (feat(#1613, #1640): EventBridge buses, per-bus rules, enable/disable, tagging provider #1701) has no Lambda dispatch path, so nothing there changes.
  • DeleteFunction: without a Qualifier, it deletes all versions, aliases, their policies and the counter. With one, it deletes a single version: a version an alias references is ResourceConflictException/409, and an alias name or $LATEST is InvalidParameterValueException.
  • CloudFormation:
    • AWS::Lambda::Version: Ref is the version ARN; GetAtt Version and FunctionArn.
    • AWS::Lambda::Alias: Ref and AliasArn are the alias ARN; the alias updates in place.
    • A Version whose function is unchanged since its last version fails with "A version for this Lambda function exists ( N ). Modify the function to create a new version." The deploy reads the newest version first. A failed replacement rolls back instead of adopting the existing version and then deleting it.
  • LastUpdateStatus: Successful in every configuration (lambda: ESM tags dropped, GetFunctionConfiguration missing, GetFunction without Tags, no LastUpdateStatus #1660 item 4). The Terraform provider's code-update waiter needs it.

Routed operations rise from 1,184 to 1,191: GetFunctionConfiguration, PublishVersion and the five alias operations. Lambda now routes 38. The branch is rebased on c3382f0, with the wire model, catalog and docs/services.md regenerated.

Provenance

Gates run locally

  • make lint test e2e
  • Both drift sets
  • docs-versions docs-counts-check
  • SUBSTRATE_IAC=1 make iac-e2e: the CDK and Terraform journeys both pass, run and replay, on a69d743
  • VitePress build, then docs/node_modules removed

Terraform scratch check (first revision; built binary, provider 6.73.0)

The config was aws_lambda_function with publish = true, aws_lambda_alias on its version, and aws_lambda_permission with qualifier.

  1. apply created version 1 and the alias. plan was empty.
  2. Changing the zip and applying again published version 2 and moved the alias in place. plan was empty.
  3. destroy was clean, and the function then answered 404.

Follow-ups

@scttfrdmn scttfrdmn added this to the v0.134.0 milestone Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.93278% with 49 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/cfn_resources_lambda.go 88.70% 14 Missing ⚠️
emulator/lambda_versions.go 95.48% 14 Missing ⚠️
emulator/lambda_aliases.go 95.70% 10 Missing ⚠️
emulator/lambda_plugin.go 94.89% 10 Missing ⚠️
emulator/scheduler_targets.go 95.65% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…tion

PublishVersion snapshots $LATEST as an immutable numbered version; aliases
with weighted routing drawn from the request's ID mint; Qualifier resolution
in GetFunction, Invoke, the permission operations and DeleteFunction, with
another account's ARN refused and the Qualifier parameter authorized against
the qualified ARN; GetFunctionConfiguration; Publish=true honoured;
AWS::Lambda::Version and AWS::Lambda::Alias CloudFormation rows; qualifiers
passed through SNS, S3, API Gateway, ESM and Step Functions invokes;
LastUpdateStatus: Successful.

Co-Authored-By: Claude <[email protected]>
@scttfrdmn
scttfrdmn merged commit 31666ee into main Nov 25, 2026
20 checks passed
@scttfrdmn
scttfrdmn deleted the feat/v0134-lambda branch November 25, 2026 01:08
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