* fix(lambda): pass LoggingConfig log format and level to the runtime
A function with LogFormat=JSON logged text: neither launcher set AWS_LAMBDA_LOG_FORMAT or AWS_LAMBDA_LOG_LEVEL, which the runtime interface clients read. Both launchers now pass them, and a JSON function without an ApplicationLogLevel gets INFO, the level the API reports, through one default shared with the response.
Closes#6774
* docs(lambda): note the log format and level the runtime receives
* refactor(lambda): build the runtime environment in one place for both launchers
ContainerLauncher and KubernetesPodLauncher wrote the same AWS_LAMBDA_* lines, the LoggingConfig ones included. LambdaRuntimeEnv.of now builds them once.
Select runtime images with the effective Docker platform while preserving runtime-wide defaults, explicit platform precedence and code-volume helper platform.
Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* feat(lambda): list provisioned concurrency configurations
Dispatch List=ALL to a paginated view of existing provisioned concurrency allocations. Preserve qualified ARNs, current status and existing pool lifecycle.
Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(lambda): share function ARN region resolution
Share the existing Lambda region validation and error message across function resolution and provisioned-concurrency lookup/listing.
Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
---------
Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Preserve the requested alias ARN while returning the resolved published version configuration. Retain snapshot-versus-latest regressions for both read APIs.
Signed-off-by: Andre Kurait <akurait@amazon.com>
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* feat(lambda): make reactive S3 sync toggleable and optionally async, reporting LastUpdateStatus while it runs
* fix(lambda): run async reactive S3 syncs as the uploader's account, keep InProgress continuous, and queue the latest source per function
* fix(lambda): clear a failed reactive sync's LastUpdateStatus on UpdateFunctionConfiguration, and test async syncs from a second account
* test(lambda): share LambdaCodeSourcesProfile for the async reactive sync test, reuse LambdaWebZips, and extract the failed-sync setup
* feat(lambda): add init-timeout-seconds so a cold runtime gets its own init budget
* fix(lambda): count the init budget from container start, apply it only until the first /next poll, and cover it in SQS visibility
* test(lambda): check the dispatch wait directly instead of on the clock, and correct the init budget docs
* fix(lambda): reject provisioned concurrency for SnapStart versions
Reject provisioned concurrency admission and configured alias retargeting for published SnapStart versions before mutation. Preserve older version snapshots and unconfigured alias behavior.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* test(lambda): remove redundant SnapStart SDK fixture
Retain the pool regressions and existing alias retarget SDK coverage as requested in review. Remove the duplicate SDK case and its custom zip construction.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
---------
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Retarget provisioned alias allocations while retaining quota and cleanup ownership. Isolate failed replacement writes or unsupported targets to their allocation so unrelated configurations continue reconciling. Retry the retained allocation when its target or storage recovers.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Initialize and route qualifier-owned provisioned environments without invoking handlers during initialization. Keep configuration outcomes committed while failed removal remains owned for retry, and bound cleanup after late invocation release. Preserve on-demand spillover and the separate alias-retargeting stage.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Add the requested control-plane stage: Put/Get/Delete validation, persistent desired configuration, qualified IAM resources, and cleanup on version, alias, and function deletion. Share the function concurrency lock with reservation changes. Runtime initialization and invocation routing remain separate.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Close admission during drain and retain failed removal ownership. Retry late releases within a separate bounded cleanup attempt, validate drain configuration at startup, and safely reopen after reset.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Floci accepted ApplicationLogLevel and SystemLogLevel under Text and
dropped them, which a test pinned and the docs described as Floci's own
call rather than probed behaviour. Measured on Lambda (eu-west-1,
2026-10-18): CreateFunction and UpdateFunctionConfiguration refuse either
level under Text, whether LogFormat names Text or is left to that
default, with InvalidParameterValueException "LogLevel is not supported
when LogFormat is set to "Text". Remove LogLevel from your request or
change the LogFormat to "JSON" and try again." In a stack, a valid level
under Text passes the template's validation and fails the resource with
Lambda's message. Floci now refuses it in validateLoggingConfig, so the
API and the CloudFormation update check, which validates through
loggingSettings, both do; and its enum errors list the levels in Lambda's
order: [FATAL, TRACE, WARN, ERROR, INFO, DEBUG] and [WARN, INFO, DEBUG].
The default format is worked out in one place, logFormat, for the
validation and for loggingSettings.
Tests: a level under Text refused on create and on update through the API
(LambdaVpcSnapStartLoggingIntegrationTest, replacing the test that pinned
the old behaviour) and through the SDK (LambdaFunctionConfigTest), by
loggingSettings (LambdaServiceTest), and by a stack update
(CloudFormationLambdaLoggingConfigIntegrationTest); the enum messages'
order. They fail on main.
* fix(lambda): send a function's logs to the log group its LoggingConfig names
Floci stored LoggingConfig.LogGroup and read it back, but every execution
environment still wrote to /aws/lambda/<name> and told the function so in
AWS_LAMBDA_LOG_GROUP_NAME. Measured on AWS (eu-west-1, 2026-10-16): a
function whose LoggingConfig names a group writes INIT_START, START, its
own output, END and REPORT there, Lambda creates the group when it is
missing, and /aws/lambda/<name> is never created. AWS_LAMBDA_LOG_GROUP_NAME
and AWS_LAMBDA_LOG_STREAM_NAME name that group and stream.
Once LoggingConfig names a group, which several functions can share, each
stream's name carries the function's name: 2026/10/16/my-fn[$LATEST]<id>
instead of 2026/10/16/[$LATEST]<id>. It does even when the group named is
/aws/lambda/<name> itself, so the rule is whether a group is named, not
whether it differs from the default.
Both launchers, Docker and Kubernetes, and GetFunctionConfiguration's
LoggingConfig now take the group and the stream from one place,
LambdaLogDestinations.
Floci skips delivering a log group to a Lambda subscription destination
that writes its own logs there, which would feed the function its own
output forever. That check assumed the group was /aws/lambda/<name>, so a
forwarder subscribed to the group its LoggingConfig names would loop. It
now asks LambdaLogDestinations for the function's group, and falls back
to the default name, from the same place, for a function it cannot find.
* fix(logs): skip only a function's own streams when it forwards its log group
The guard that keeps a subscription from feeding a Lambda destination its
own output looked the function up by name in the caller's account and
Region at $LATEST, and skipped the whole group once it matched. In a group
LoggingConfig names, which several functions can share, a forwarder then
lost every other function's logs; a destination naming a published version
or alias was checked against $LATEST's group; and a function in another
account than the ambient one was not found, so its own custom group was
fed back to it.
The function is now the one the destination ARN names, through
getFunctionByArn, with its account, Region and qualifier, and in a named
group only the streams carrying its name are skipped, the shape measured
on AWS for a named group (2026/10/16/<name>[$LATEST]<id>); every stream of
the default group is still the function's own. A destination ARN that
does not parse as a function's is not a loop and is no longer caught as
any RuntimeException.
Tests: another function's stream in a shared group reaches the
forwarder while its own is skipped, and a destination naming a published
version is checked against that version's group (both fail on the
previous head); the stream ownership rule in LambdaLogDestinationsTest.
* fix(docker): preserve explicitly configured DNS resolvers
Honor explicit --dns entries before injecting the embedded resolver and public fallbacks. Keep automatic DNS for containers without configured resolvers, and verify the shared builder and Lambda launcher preserve the requested list.
Signed-off-by: Andre Kurait <akurait@amazon.com>
* fix(lambda): keep AWS endpoints reachable with explicit DNS
Signed-off-by: Andre Kurait <akurait@amazon.com>
---------
Signed-off-by: Andre Kurait <akurait@amazon.com>
Under IAM enforcement, SES published event-destination events and identity notifications to
whatever SNS topic it was configured with, through an internal call nothing checked, so a caller
refused sns:Publish could still put messages on a topic by pointing a configuration set at it. On
AWS, SES publishes as ses.amazonaws.com and the topic's policy decides: it has to allow SES, under
an aws:SourceArn naming the configuration set or identity whose configuration names the topic.
- ServiceCallAuthorizer decides a call one AWS service makes to another's resource on its own
behalf from the target's resource policy alone, read through the same providers the request
filter uses and picked by the target ARN's service. A target with no policy refuses, and with
enforcement off every call is allowed. ResourcePolicyProviders collects what the providers
supply, for the filter and the authorizer alike.
- IamConditionContextResolver.serviceCallContext builds that call's request context from the IAM
User Guide's global keys: aws:PrincipalIsAWSService, aws:PrincipalServiceName and
aws:PrincipalServiceNamesList, aws:SourceArn and aws:SourceAccount, aws:ResourceAccount and
aws:RequestedRegion, and none of the keys that describe an IAM principal. A publish to an SNS
topic from SES also carries aws:SourceOwner, which the SNS Developer Guide lists SES among the
services setting, and which the default topic policy checks.
- SnsResourcePolicyProvider supplies a topic's policy and the account in its ARN, also when the
topic does not exist. A topic with no Policy attribute gets the default a new topic has, for the
topic's own account. Topic policies so also take part in a JSON-protocol request that names a
topic, as any resource policy does.
- SesEventPublisher asks before publishing to SNS: for an event destination with the configuration
set's ARN, for an identity notification with the ARN of the identity that names the topic, the
sender's own or its domain's, both with the sending account. A refused event is dropped. A
notification SES cannot publish, because the topic is gone from its own account or its policy
refuses SES, also takes the topic out of the identity's bounce and complaint settings and turns
email feedback forwarding back on, as the SES Developer Guide describes; a delivery setting
stays. The identity's notification settings are written under the identity lock, so that
write and an API call changing them cannot lose each other.
- CreateReceiptRule and UpdateReceiptRule ask the same question of an action's TopicArn, with the
rule's ARN as aws:SourceArn, and answer InvalidSnsTopic when the topic's policy does not let SES
publish, which the SES API Reference lists as "could not publish to the topic, possibly due to
permissions issues". The rules still route no mail.
- A resource policy statement that names the caller only through its account, by its id, root ARN
or S3 canonical user ID, delegates to that account (IAM User Guide, "AWS account principals"):
across accounts it is still the owner's half of the grant, but within the account it no longer
grants on its own, and the caller's identity policies have to allow the request. Floci let such
a statement grant on its own, for bucket and function policies already, so a topic policy naming
its own account would have let every user of the account publish.
- A Deny's NotPrincipal follows the IAM User Guide ("AWS JSON policy elements: NotPrincipal"): it
spares an IAM caller only when it names the caller's account as well as the caller, since without
the account AWS "might deny access to the entire account", and never spares one with a permissions
boundary attached, which it "will always deny". CallerArns says whether a boundary is attached to
the user or to the role a session assumed. An Allow's NotPrincipal still grants everyone it does
not name, as Access Analyzer warns it can.
The AWS GovCloud (US) User Guide lists "AWS Lambda Function URLs is not
available"
(https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-lambda.html)
and the China guide "Amazon Lambda Function URLs is not available in the
China Regions"
(https://docs.amazonaws.cn/en_us/aws/latest/userguide/lambda.html), but
CreateFunctionUrlConfig created one in every partition, on a host no
source publishes for either of them.
CreateFunctionUrlConfig now refuses a request whose region is in
aws-us-gov or aws-cn with an InvalidParameterValueException, which the
lambda model declares for the operation. No source shows AWS's message,
so the wording is Floci's own, as for the API Gateway EDGE gate. The
AWS::Lambda::Url provisioner creates through the same service method, so
a stack in those partitions fails with that error. Get, Update and Delete
act on an existing config and are unchanged. The ISO and EUSC partitions
are left as they are because no source covers them, and the open
question about the function URL host now names only those two.
The Java compat suite skips LambdaFunctionUrlTest in those two partitions,
so the China partition nightly stays green.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
Under IAM enforcement, a Lambda task naming a function in another account was refused outright,
because Floci evaluated no Lambda function policy when #5079 added the check, and a task on a
function in the state machine's own account was not checked at all. Function policies now take
part in authorization (#5476), so a task is decided the way Lambda decides the Invoke call the
execution role makes (Step Functions Developer Guide, "I can't invoke a Lambda function from
another account"): within one account the role's policies or the function's policy can allow it,
and across accounts both have to (IAM User Guide, cross-account policy evaluation logic).
- LambdaTaskAuthorizer evaluates the role's policies, its permissions boundary and its account's
SCPs together with the function policy LambdaResourcePolicyProvider supplies. The role ARN has
to name an existing role, path included, matched as STS AssumeRole matches one
(IamService.roleArnMatches), and the role is evaluated under the ARN IAM holds for it.
- The task is authorized against the function ARN LambdaArnUtils.functionArn gives for its
reference: a full ARN as written, a name or partial ARN completed in the state machine's
partition, Region and account, with the version or alias it names, as Lambda authorizes an
invoke.
- A task whose Credentials name a role invokes the function as that role, once the execution role
has assumed it (Developer Guide, Task state "Credentials"). The role's trust policy has to allow
the execution role, with the state machine's ARN as sts:ExternalId, which the cross-account
tutorial's trust policy checks. The execution role's own policies have to allow sts:AssumeRole
on the role too when it is in another account, or when the trust policy names only the execution
role's account, since an account principal delegates to the account (IAM User Guide, "AWS
account principals"); AssumeRolePolicyEvaluator.decide tells the two grants apart. RoleArn is
read the way the task's Parameters or Arguments are. A role the execution role cannot assume
fails the task with States.Permissions, the Developer Guide's error for a task without the
privileges to run.
- A refusal to invoke fails the task with Lambda.AccessDeniedException. The cause names the role's
session as the Step Functions Developer Guide shows it
(arn:aws:sts::<account>:assumed-role/<role>) and ends in the IAM User Guide's context for the
policy type that refused it, explicit denials first, each in AWS's evaluation order: service
control policies, the resource-based policy or role trust policy, identity-based policies, the
permissions boundary.
* docs(partition): bring the partition pages up to date with the smoke coverage and EDGE rules
partitions.md still listed the eleven services the smoke test started with
and said Step Functions runs in all eight partitions through the emulator,
which only IAM does. It now states the rule (every minting service has a
case or a listed exemption), names EUSC among the partitions without
CloudFront, and replaces the sign-in client id open question, which the
model answers, with the one that is open: the cross-device redirect host.
lambda.md said a layer ARN outside the aws partition is refused; the check
is against the caller's partition. appsync.md implied the AppSync service
principal varies by partition; it does not.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* docs(partition): note the endpoint's own origin in the cross-device redirect question
Since #5552 the cross-device redirect is also accepted on the endpoint
the authorize request arrived on, so the open question is only about
which AWS host is accepted outside the commercial partition.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
---------
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* fix(cloudformation): expand a SAM function's EventInvokeConfig
SAM's EventInvokeConfig was dropped, so a function declaring retries, a maximum
event age or invoke destinations deployed with Lambda's defaults and no
destination at all. It now expands as AWS's SAM translator expands it: an
AWS::Lambda::EventInvokeConfig on $LATEST or the AutoPublishAlias alias, the
inline role policy for each destination, the SQS queue or SNS topic SAM creates
for a destination given only its Type, and SAM's conditions and error messages.
The function's Condition, DeletionPolicy and UpdateReplacePolicy now reach every
resource generated for it, as SAM passes them through. A condition naming another
with anything but a string is rejected as CloudFormation rejects it, which also
fails the template SAM produces for a conditional function with a conditional
destination, as on AWS.
* fix(cloudformation): resolve SSM parameters for the SAM transform and omit NoValue destinations
CloudFormation resolves an AWS::SSM::Parameter::Value<String> parameter before it
runs the SAM transform, so a destination Type taken from one is the stored value.
The transform now gets the given parameter values over each Default, with
SSM-typed parameters read from Parameter Store, wherever it runs.
A Destination of AWS::NoValue passes through SAM unchanged and leaves its side
without an ARN, which CloudFormation's validation rejects. The event invoke config
provisioner resolved it to an empty string and stored that; it now omits
AWS::NoValue, so the destination fails as the schema requires.
* refactor: share SHA-1 as Digests.sha1
The SAM transform's generated condition names, EC2 key pair fingerprints and
the SAML assertion name qualifier each made their own one-shot SHA-1 digest.
They now share Digests.sha1 beside sha256. Also moves samTransformParameters
above resolveSsmParameters' Javadoc, which it had been inserted beneath.
* fix(lambda): expose the executing version on cold launches
Signed-off-by: Andre Kurait <akurait@amazon.com>
* fix(lambda): propagate executing version to Kubernetes pods
Signed-off-by: Andre Kurait <akurait@amazon.com>
---------
Signed-off-by: Andre Kurait <akurait@amazon.com>
Under IAM enforcement, a caller whose own policy allowed lambda:InvokeFunction could invoke
another account's function by ARN even when that function's policy granted nothing, and
RotateSecret could be pointed at another account's function the same way. Three things combined:
there was no resource-policy provider for Lambda, so the call was judged as same-account; the
function name was cut at its first colon, so an ARN was evaluated as function:arn in the caller's
account, where no Allow or Deny written for the function could match; and the invoke followed the
account in the ARN.
- LambdaResourcePolicyProvider supplies a function's policy statements and the account its ARN
names, also when the function has no policy, so a call to another account's function needs that
function's policy to allow the caller as well as the caller's own policy. It is keyed on the
ARN, so RotateSecret's check on its rotation function, made under the secretsmanager scope,
sees it too.
- ResourceArnBuilder evaluates each call against the function it acts on. An invoke runs in the
account and Region a full or partial ARN names, as the version or alias it names in the function
name or in Qualifier, since Lambda authorizes a qualified call against the qualified ARN.
GetFunction, GetFunctionConfiguration and ListDurableExecutionsByFunction read a qualified full
ARN in the account it names, so they are evaluated there too, and a read of another account's
function needs its policy as on AWS. Every other route acts on the caller's own function of that
name, so it is evaluated against that function, unqualified because not all of their handlers
act on the qualifier.
- An invoke by partial ARN runs in the account it names, as one by full ARN already did.
- RotateSecret looks its function up where the rotation runs it: in the ARN's account, and as the
version or alias the ARN names.
* feat(cloudformation): pass Lambda DurableConfig through
AWS::Lambda::Function.DurableConfig reaches CreateFunction and
UpdateFunctionConfiguration. As on AWS, a RetentionPeriodInDays the
template leaves out is 14 on update too, a durable function created
without Timeout gets min(ExecutionTimeout, 900), and adding or removing
DurableConfig replaces the function.
* test(terraform): cover aws_lambda_function durable_config
The provider creates a durable function, reads it back without a diff,
updates execution_timeout in place, and before destroy stops a RUNNING
durable execution through ListDurableExecutionsByFunction,
StopDurableExecution and GetDurableExecution.
* fix(cloudformation): honor AWS::NoValue, cleared keys and large numbers in DurableConfig
A DurableConfig that Fn::If removes with AWS::NoValue leaves the
function plain. A KMSKeyArn the template leaves out or sets to "" clears
the key, as CloudFormation does on AWS, since Lambda keeps a stored key
when the update omits the member. A number beyond an integer reaches
Lambda unchanged, so its range check rejects it.
* fix(cloudformation): reject a DurableConfig that is not an object
Only an intrinsic that resolves to AWS::NoValue removes DurableConfig.
CloudFormation rejects a string, number or list in its schema check
before the function is touched, so an update with one no longer
replaces and deletes a durable function.
* test(cloudformation): cover Lambda DurableConfig with the AWS SDK
The CloudFormation and Lambda SDK clients create a durable function,
update DurableConfig in place, and remove it by replacing the function.
* fix(cloudformation): require ExecutionTimeout and known members in DurableConfig
CloudFormation checks DurableConfig against the schema on update too: an
update without ExecutionTimeout, or with a member the schema does not
list, fails before the function is touched. Floci let such an update
through and kept the old timeout.
* refactor(cloudformation): look up a Lambda function once per deploy
The name choice and the replacement decision now share one lookup and one
durable check, so they cannot disagree.
* feat(lambda): durable function chained invokes
A CHAINED_INVOKE operation runs another function. A durable target
needs a version or alias and runs as its own durable execution with a
random name; its close completes the operation as SUCCEEDED, FAILED,
TIMED_OUT ("CHAINED_INVOKE timed out after N seconds.") or STOPPED. Any
other function is invoked once, and an output over 1 MB fails the
operation. A missing function or an unqualified durable one fails the
operation at once. Stopping the parent leaves the child running.
A plain chained invoke lost with the process runs again after a restart,
and a durable child that closed before its report reaches the parent
reports then.
* fix(lambda): close the gaps in durable chained invokes
A durable child that closes during a restart reports to its parent
under its own lock, and recovery triggers an execution once. A durable
target invoked without Payload starts its child with no input, while a
plain target gets {}. A target started in the batch that closes the
execution still runs and its result is ignored, as on AWS.
* fix(lambda): reject a chained invoke of another account or region
AWS rejects the checkpoint with InvalidParameterValueException "Cannot
start a CHAINED_INVOKE on a function in another account." or "... in
another region." Cross-account chained invocations are not supported.
* fix(lambda): keep durable chained invokes across a crash
The parent is saved before the child it starts, so a crash in between
leaves no child the parent does not know. On restart a child the parent
recorded but the store lost is started again under the same ARN, and a
plain target started by the checkpoint that closed the execution runs
again until its result is recorded. A child reports only to the
operation that started it.
* fix(lambda): recreate a lost durable child on the version its ARN names
An alias the chained invoke named may point to another version after a
restart, and a child recreated there would not match the ARN the parent
saved.
* feat(sqs): thread accessKeyId through RequestContext and AccountContextFilter
* fix(iam): resolve caller user id and align assumed role id with role id
* feat(sqs): stamp senderId on Message model and in SqsService
* feat(sqs): return message-specific senderId in SQS query and JSON handlers
* test(sqs): add integration tests for SenderId caller principal (#4829)
* fix(sqs): guard against unsatisfied CDI instance in resolveCurrentSenderId
* fix(sqs): address review findings and fix CI for caller principal SenderId
- Catch RuntimeException in SqsService to prevent compiler incompatibility
- Fallback SenderId to queue owner account when outside request context
- Deliver SNS fanout messages with SNS service principal SenderId
- Support presigned requests without X-Amz-Algorithm in AccountContextFilter
- Populate assumedRoleId and roleSessionName for ECS, EKS and Lambda sessions
* fix(sqs): validate session token for temporary credentials and fix CI regressions
- Validate session token matching when resolving caller principal for temporary credentials
- Generate unique session names for EKS Pod Identity to avoid sender ID collision
- Restore default floci-session session name for Lambda execution role sessions
- Align SqsService mock in SnsServiceTest with 9-parameter sendMessage signature
* fix(sts,lambda): pass sessionToken to resolveCallerUserId and scope Lambda assumed role IDs
* fix(lambda): align execution role session name and assumed role ID with function name
* fix(sqs): resolve SenderId caller in SQS handlers, not in sendMessage
Internal producers (S3 notifications, EventBridge, SNS) call sendMessage
on the thread of the request that triggered them, so SenderId picked up
that caller's role session. Resolve the caller in the SQS Query/JSON
handlers where a real SendMessage call is known, and pass it down.
sendMessage without an explicit senderId now defaults to the queue owner.
* feat(lambda): durable function callbacks
A CALLBACK operation started at checkpoint gets a callback id that
SendDurableExecutionCallbackSuccess, Failure and Heartbeat complete or
keep alive, after which the function is invoked again to see it.
TimeoutSeconds and HeartbeatTimeoutSeconds time it out with
Callback.Timeout or Callback.Heartbeat. A completed, timed out or
stopped callback answers CallbackTimeoutException, an unreadable id
"Invalid callback id". The callback id carries the execution ARN, which
IAM authorizes the callback actions against.
Option range errors now name the update, as AWS does
("updates.1.member.waitOptions.waitSeconds").
* fix(lambda): name a repeated durable update as AWS does
AWS rejects two updates of one operation in a batch, other than a START
closed by its STEP or CONTEXT action, with "Cannot update the same
operation twice in a single request."
* fix(lambda): leave a durable execution waiting after a body-less callback failure
AWS marks a callback failed with an empty request body as FAILED but does
not invoke the function again, so the execution keeps waiting. The SDKs
send {} when Error is omitted, which does invoke it.
* fix(lambda): bound a durable callback failure's error at 1 MB
AWS rejects an Error over 1048576 bytes, measured as compact JSON, with
InvalidParameterValueException "Error object size must be less than or
equal to 1048576 bytes."
* test(lambda): keep a pending durable callback across a restart
* fix(lambda): reject a durable callback failure body that is not a JSON object
AWS treats only an empty body as a failure with no Error. Whitespace,
null or broken JSON get 400 SerializationException and leave the
callback open.
* docs(lambda): note the durable callback result limit AWS enforces
* feat(lambda): run durable functions with checkpoints, waits and step retries
Invoking a durable function starts a durable execution, through Invoke or through an ARN (EventBridge, Scheduler, function URLs, destinations). The function checkpoints through CheckpointDurableExecution and GetDurableExecutionState, and Floci re-invokes it when a wait or a step retry comes due. GetDurableExecution, GetDurableExecutionHistory, ListDurableExecutionsByFunction and StopDurableExecution read and stop executions. Timers are persisted deadlines fired by a background sweep, so an execution survives a restart. Callbacks and chained invokes are rejected at checkpoint time.
* fix(iam): authorize durable execution actions against the owning function
A durable execution route has no /functions/ segment, so its resource fell back to *. The function name now comes from the execution ARN in the path.
* fix(lambda): keep durable executions inside their account
The execution APIs took the account from the ARN in the path, so another account could read or stop an execution. An ARN of another account is now ResourceNotFoundException.
* fix(lambda): limit the error size of an EXECUTION checkpoint too
* fix(lambda): reject an EXECUTION close that carries the other result kind
AWS rejects SUCCEED with an Error and FAIL with a Payload on the EXECUTION operation, as it does for steps.
* fix(lambda): spend a durable wake-up when a failed invocation schedules its retry
* fix(lambda): keep a durable crash retry's backoff across a restart
* fix(lambda): bound the durable execution locks
A lock per execution ARN was kept forever, even for an ARN that did not exist. A fixed set of striped locks replaces it. Locks are never nested, so a shared stripe cannot deadlock.
* fix(lambda): accept PAUSED, PAUSING and DELETING as durable status filters
AWS accepts them and answers an empty list, since Floci never puts an execution in those states.
* fix(lambda): reject a non-finite durable list timestamp
* test(lambda): resume a durable execution from its JSON file after a restart
* fix(lambda): keep durable executions inside their region
An execution ARN of another region now answers ResourceNotFoundException "Function not found", as AWS does, instead of reaching the execution past the IAM check of the request region.
* fix(lambda): validate durable list parameters before an empty status filter answers
Statuses of only PAUSED, PAUSING or DELETING still checks MaxItems and Marker, as AWS does. The bad Marker message is "Invalid Marker".
* perf(lambda): skip the execution scan for a status filter that matches nothing
Statuses of only PAUSED, PAUSING or DELETING now checks MaxItems and Marker without listing the account's executions.
* test(lambda): drop durable tests that repeat other coverage
The in-memory restart test repeats the persistence test, and the Docker success case repeats the compat suite's checkpoint loop. The Docker test keeps the failure case.
* fix(lambda): re-attach a durable execution name only on the same version
AWS keeps execution names unique per function across versions. A sync Invoke of another version with the same name and payload is DurableExecutionAlreadyStartedException, not the existing execution.
* chore(lambda): simplify the durable execution engine
Drop stored fields nothing reads, share the unseen-operations and
page-cursor helpers, skip the name scan for a generated name, and save
an execution once per invocation instead of twice.
* fix(lambda): reject a non-integer durable MaxItems as AWS does
AWS answers MaxItems=x on the durable execution APIs with
SerializationException "'x' can not be converted to Integer".
* docs(lambda): list the durable execution size limits as not emulated
* fix(iam): authorize durable execution actions against the execution ARN
The durable execution actions take the durable execution resource,
function:name:version/durable-execution/name/id. A role allowed on
function:name:* may checkpoint, one allowed only on the unqualified
function ARN is denied.
* fix(lambda): answer an unknown durable execution on checkpoint as a bad token
CheckpointDurableExecution and GetDurableExecutionState do not model
ResourceNotFoundException. AWS answers InvalidParameterValueException:
"Checkpoint token is not valid for the durable execution ARN" for a
token minted for another execution, "Invalid checkpoint token" otherwise.
* fix(lambda): replay a durable checkpoint retried with the same ClientToken
AWS answers a retry of the last checkpoint with the same ClientToken
with the same state and a usable next token, even though the request
token is spent. A different ClientToken, a retry after the next
checkpoint, or a retry of the checkpoint that closed the execution is
still an invalid checkpoint token.
* fix(lambda): validate durable list filters as AWS does
ListDurableExecutionsByFunction takes one status at most and answers
more with InvalidParameterValueException "Cannot filter by more than one
status". An unreadable StartedAfter or StartedBefore is
SerializationException "'<value>' can not be converted to Date", and a
plain date is accepted. Type errors come first, then MaxItems and status
values, then the single-status rule, then the function lookup.
* docs(lambda): note the history IncludeExecutionData default
* fix(lambda): report durable MaxItems and Statuses errors as AWS does
AWS puts an invalid MaxItems and an invalid Statuses into one
ValidationException ("2 validation errors detected: ...; ..."), MaxItems
first. A negative MaxItems must be greater than or equal to 0. MaxItems
is checked before the execution or function is looked up.
* refactor(lambda): share one durable execution ARN pattern with IAM
IAM and the durable execution service now recognize an execution ARN
with the same pattern, the one AWS validates it with.
* fix(lambda): replay a durable checkpoint answer as it was sent
On AWS a retry with the same ClientToken returns the operations as the
first answer had them: a WAIT stays STARTED in the retry even after it
has elapsed, while a fresh checkpoint reports it SUCCEEDED.
* feat(lambda): accept and echo DurableConfig on functions
CreateFunction and UpdateFunctionConfiguration take DurableConfig, PublishVersion snapshots it, and every read echoes it. ExecutionTimeout is required on create, RetentionPeriodInDays defaults to 14, a durable function's Timeout defaults to min(ExecutionTimeout, 900) and its logging to JSON. Update merges the members, and a function created without DurableConfig cannot gain one. KMSKeyArn is validated against its pattern and stored, the key itself is not looked up.
* chore(lambda): trim the DurableConfig tests to one case per rule
* feat(lambda): durable functions log in JSON format only
A durable function rejects LogFormat Text on create and update, and a LoggingConfig without LogFormat reads back as JSON. An empty KMSKeyArn means no key.
* chore(lambda): let the logging helpers own the durable JSON rule
validateLoggingConfig and applyLoggingConfig take the durable flag, so a durable function's default format and the Text rejection live in one place and a LoggingConfig without LogFormat keeps its log levels. applyDurableConfig sets the retention default and merges, and the test uses chainable helpers.
* chore(lambda): say why the durable compat test ignores a failed cleanup
* feat(lambda): bound the warm pool globally with LRU eviction
Adds warm-pool-max-per-function (replaces the hardcoded max(4, cpus)) and warm-pool-max-total (0 = unbounded). When the total would be exceeded, the least-recently-used idle container of any function is stopped before the released one is pooled, so the function that just ran keeps its container. Busy containers are not counted; their ceiling is region-concurrency-limit.
WarmPool now takes a Clock so LRU order and the idle sweep are testable without sleeping.
Closes#4682
* fix(lambda): warn when warm-pool-max-total is negative instead of treating it as unbounded
Math.max(0, value) turned -1 into 0, the documented opt-out, so a mistyped cap silently restored the unbounded pool. Resolve it like warm-pool-max-per-function: a negative value is logged and the total stays unbounded.
* docs(lambda): state the warm-pool peak bound per region
region-concurrency-limit applies independently in each region while warm-pool-max-total is emulator-wide, so a single sum understated peak container count with more than one active region. Describe the cap as an idle-only, emulator-wide bound and the peak as the cap plus in-flight invocations across every active region. Also document that a negative value is ignored with a warning.
* fix(lambda): do not stop a drained container again from the global cap eviction
evictIdleBeyond snapshots each idle deque, then removes the chosen handles under the pool lock. drainEnvironment and drainFunction detach the deque from the pool and stop its contents themselves, so a drain between the snapshot and the removal left the eviction holding the orphaned deque: remove(handle) still returned true and the container was stopped a second time. Check the deque is still the live one for its environment before removing from it.
* test(lambda): qualify CloudFormation mapping execution
A stack-created SQS mapping now has a compatibility test that sends messages through it: the filter drops and deletes a nonmatching message, the batching window holds a batch open until a later message joins it, and a partial batch response retries only the reported message. The Lambda docs no longer claim CloudFormation drops FilterCriteria, and they describe SQS failure and partial batch handling.
* test(lambda): widen the mapping window margin and read every log page
The third message must join the batch while the window is still open, so a 10 second window leaves room for a stalled runner. FilterLogEvents can return a partial page with a token, so the batch log is read through the paginator.
* test(lambda): drop the stack-created SQS delivery test
SqsEventSourcePollerTest already pins the batching window, the filter and partial batch responses with an injected clock, so the wall-clock delivery test only added a race and long polls. The stored-property checks stay.
* fix(lambda): include the resource namespace in code volume names
Code volumes, their completion markers and the populate helper container are
named through prefixedDockerName, so FLOCI_DOCKER_RESOURCE_NAMESPACE follows the
container name prefix as it already does for Lambda containers. Two namespaced
instances on one daemon no longer share a code volume, and one's superseded-volume
cleanup can no longer remove the other's. Names are unchanged without a namespace.
* fix(lambda): keep two resource namespaces from sharing a code volume
Greptile and pgermosen on #4872: a namespace and a function name may both
contain dashes, so namespace ci with function foo-code-bar and namespace
ci-code-foo with function bar spelled the same volume name for the same code,
and the superseded sweep, which works from a per-process map of names, could
remove the other instance's volume. A namespaced code volume name now ends with
a short hash of the namespace (names without a namespace are unchanged), and the
sweep checks the volume's floci_namespace label before deleting, so a volume of
another namespace is left alone however its name parses.
Also imports the Mockito types in ContainerLauncherCodeVolumeReuseTest instead
of qualifying them inline.
* feat(lambda): honour the Invoke Qualifier query parameter
* feat(lambda): wait between asynchronous retries as AWS does
A failed Event invocation now waits floci.services.lambda.async-retry-delay-seconds before its first retry and twice that before its second (default 60, matching AWS), capped at the event's remaining maximum age. The concurrency permit is held only for each attempt, and an emulator reset drops retries still waiting.
* test(lambda): prove asynchronous retries end to end
* docs(lambda): document asynchronous retry timing and the Invoke Qualifier
* fix(lambda): drop retries of deleted functions and tighten async retry edges
- Drop a pending asynchronous retry when its function (or version) was deleted.
- Decide expiry once, on the injected clock, when a retry is scheduled.
- Check the reset generation at routing, so no stale outcome is delivered.
- Restore upstream behavior when an attempt throws: stop retrying and route
the previous result, or UnknownError when there is none.
- Harden tests: in-order permit release, deterministic reset, error types
and an unqualified-ARN Qualifier case for Invoke.
* fix(lambda): drop a deleted function's pending events on every path
Replace the store lookup with a per-function deletion counter, captured
when the event is invoked and checked wherever an event is attempted or
routed. This covers the expiry path, which bypassed the old check, and a
delete-and-recreate of the same name during the wait, which the lookup
could not see. Verified against AWS that DeleteFunction drops pending
retries without delivering a record.
* fix(lambda): clear deletion counts before bumping the reset generation
An invoke between the two statements of clear() captured the new
generation with a stale deletion count and its event was dropped.
The expiry-path deletion test now drops inside the first attempt,
so it no longer races the one-second maximum event age.
* fix(lambda): keep deletion counts across a reset
Clearing them while the old generation was still current let a
deleted function's pending event see a zero count and be routed.
A reset now only bumps the generation, in one atomic step.
* fix(lambda): drop an Event invoke that races DeleteFunction
An Event invoke that resolved the function just before a concurrent
DeleteFunction could take its deletion-count snapshot after the delete
had already moved the count. The event then never looked stale, so the
deleted function could still be started and a failure record could
still reach its destination.
DeleteFunction now moves the deletion count only after the function has
left the store, and an Event invoke checks that the function is still in
the store after it takes its snapshot and before it queues the event.
Either the check sees the function gone and the invoke answers 202
without queueing anything, or the snapshot predates the count change and
the event is dropped as stale later.
* fix(lambda): validate the Invoke Qualifier query parameter
Invoke treated an empty or blank Qualifier as if none had been given
and ran $LATEST, and it passed a qualifier longer than 128 characters on
to the lookup, which answered 404. AWS rejects both with a 400.
A supplied Qualifier must now be 1 to 128 characters of letters,
digits, $, _ and -, or Invoke fails with ValidationException. The
controller reads the parameter from the raw query, because @QueryParam
reports a present but empty value as null and the check could not see
it.
* fix(lambda): stop pending events before a delete or reset removes state
DeleteFunction moved a function's deletion count only after it had
removed the function's code and store entry. A retry whose timer fired
in that gap still passed the staleness check, tried to start a function
with no code, and could deliver a failure record to its destination. An
attempt that finished in that gap could deliver its OnFailure record.
DeleteFunction now moves the count before it deletes anything, which
stops every queued or running event, and again after the store entry is
gone, which stops an Event invoke that read the count in between.
An emulator reset wiped storage before the executor's clear() moved the
reset generation, so a retry firing during the wipe could run or deliver
against half-cleared state. The executor now also moves the generation
in beforeReset(), which runs before the wipe. clear() still moves it, to
drop events accepted between the two.
* test(lambda): fix a doc comment and name the tolerated Docker ping failure
The class comment now reads "wait as they do on AWS". The Docker ping
check names its caught exception "expected" and says why returning
false is safe: the test is then skipped rather than failed.
* fix(lambda): count version and alias invokes against the function's reservation
Routing the Invoke Qualifier to a published version meant a qualified
invoke took its permit against the version's snapshot, which carries no
reservation, so a reserved concurrency of 0 on the function no longer
throttled it and a positive one stopped counting those invokes. The
name-qualified path (fn:1, fn:alias) already had the same gap.
Reserved concurrency is function-wide in AWS, so the executor now takes
the permit against the function's $LATEST record, which holds the
reservation. That covers direct Invoke with a Qualifier, qualified names
and ARNs, aliases, event source mappings and asynchronous retries alike.
It reads the stored record rather than the limiter's region registry
because event source pollers can invoke before LambdaService has
rehydrated that registry after a restart.
* fix(lambda): drop a deleted function's pending events before draining its containers
DeleteFunction drained the warm pool before fencing pending asynchronous
events, and draining blocks while idle containers stop. A retry whose
timer fired in that window still passed the staleness check and could
cold-start a container after the drain, leaving it warm for a function
that no longer exists. The fence now goes up first.
* fix(lambda): apply FunctionResponseTypes on UpdateEventSourceMapping
UpdateEventSourceMapping ignored FunctionResponseTypes, so turning
ReportBatchItemFailures on or off for an existing mapping succeeded but
changed nothing: GetEventSourceMapping kept the old list and the pollers
kept retrying whole batches. Apply the member when present, sharing the
create path's parsing; an empty list clears it.
* fix(lambda): validate FunctionResponseTypes on event source mappings
AWS accepts at most one FunctionResponseTypes entry, and only
ReportBatchItemFailures. Reject anything else with
InvalidParameterValueException on both CreateEventSourceMapping and
UpdateEventSourceMapping instead of storing it.
* fix(lambda): validate every UpdateEventSourceMapping member before applying any
A request that failed on a later member (FunctionName in another region,
empty Topics) still changed the members parsed before it on the stored
mapping, which the pollers share. A JSON null FunctionResponseTypes is now
an absent member, and a non-array value is a SerializationException rather
than silently clearing ReportBatchItemFailures.
* fix(lambda): honour ReportBatchItemFailures on Kinesis event source mappings
The Kinesis poller checkpointed the whole batch after a successful invoke,
so records the function reported in batchItemFailures were never retried.
It now checkpoints just before the lowest reported record and retries the
whole batch on a malformed response, matching the DynamoDB Streams poller.
* fix(lambda): return event source mapping ARN and support tagging mappings
CreateEventSourceMapping now stores Tags, every mapping response carries
EventSourceMappingArn, and TagResource/ListTags/UntagResource route
event-source-mapping ARNs to the mapping instead of rejecting them as
non-function ARNs.
* fix(lambda): address review on event source mapping ARN and tags
- CloudFormation builds EventSourceMappingArn from the region and account
the mapping is stored in, not the stack's, so it matches Lambda's ARN.
- TagResource rejects a non-object Tags or a non-string tag value with
SerializationException instead of persisting it.
- The tag APIs match a mapping ARN exactly, so an ARN in another partition
is reported as ResourceNotFoundException.
- Explain the tolerated teardown failures in LambdaEsmTagsTest.
The shared DockerClient's connection pool was hard-coded to 100. Each live
Lambda container holds two of those connections for its whole lifetime
(the followed log stream and the exit watcher), so about 50 warm
containers exhaust the pool. Create, start, stop and remove then wait for
a free connection, including the idle-container stop that would release
one, and the emulator stalls.
Expose the size as floci.docker.max-connections
(FLOCI_DOCKER_MAX_CONNECTIONS), reject values below 1, and default it to
1024 so that the 500-port Lambda runtime API range, not the Docker pool,
is the ceiling on concurrent Lambda containers.
Refs #2219, #2224
Co-authored-by: Goooooooooody <205637002+Goooooooooody@users.noreply.github.com>
* refactor(dynamodb): add a stream reader and key native streams by table ARN
DynamoDbStreamReader is the engine-neutral way to read DynamoDB Streams.
DynamoDbApiStreamReader implements it over the selected DynamoDbOperations using the Streams wire API.
Native streams were keyed by region and table name, so same-named tables in two accounts shared one stream.
They are now keyed by table ARN, and ListStreams returns only the caller's account and region.
Streams of every account are restored from persisted tables at startup.
* refactor(dynamodb): move stream consumers onto the stream reader
The Lambda DynamoDB Streams poller reads through DynamoDbStreamReader: each tick renews iterators from committed progress for every readable shard, and reads a child shard only after its parent was read to its end.
It discards restart checkpoints only for a process-lifetime engine, and pins LATEST per shard via newestSequenceNumbers, replacing DynamoDbStreamService.latestSequenceNumber.
A read fills a batch from as many GetRecords calls as it needs, so a batch is not cut at the 1000 record GetRecords maximum.
EventBridge Pipes reads DynamoDB streams the same way, committing a batch only once it is delivered or sent to the DLQ, delivers the AWS stream record shape with eventSourceARN, and honors LATEST.
The Redshift zero-ETL consumer reads the same way, keeping per-shard progress in the integration (legacy checkpointSequenceNumber is ignored on load) and committing a batch only after it is written to the landing table.
It discards that progress at startup for a process-lifetime engine, and the writer now takes AWS stream records, so Redshift no longer uses DynamoDbStreamService or DynamoDbStreamRecord, whose SHARD_ID is now package-private.
* fix(lambda): support async retries and dead-letter queue (DLQ)
- Add retry loop honoring MaximumRetryAttempts and MaximumEventAgeInSeconds in LambdaExecutorService
- Deliver original payload and message attributes (RequestID, ErrorCode, ErrorMessage) to SQS/SNS DLQ in AsyncInvokeDestinationRouter
- Give precedence to OnFailure destination over DeadLetterConfig
- Wrap EventInvokeConfig queries in RequestScopes.callAs for correct account partitioning
- Add comprehensive unit and integration tests covering retries and DLQ delivery
Closes#4194
* test(lambda): cover cross-account DLQ delivery
* fix(lambda): add missing async destination test helper
* test(lambda): allow async retry attempts in chain guard test
* fix(lambda): preserve async result on age expiry
A DynamoDB Streams mapping created with StartingPosition LATEST is now
pinned after the stream's newest record at creation, so only later
writes are delivered. Previously every mapping without a checkpoint
started from TRIM_HORIZON.
The poll worker now re-reads the stored mapping after its fetch and
skips the batch when the mapping was deleted or disabled meanwhile. An
invocation still running when the mapping is deleted completes, but
its result is dropped: no retry state, no OnFailure destination send,
and no checkpoint write that would re-insert the mapping into the
store. This also covers a state reset racing an in-flight poll.
Refs #4311
BisectBatchOnFunctionError now splits a batch that fails with a function
error in half, keyed by checkpoint, until the poison record is isolated.
Splits do not consume the retry quota; throttles and partial batch
responses do not split.
A discarded batch whose OnFailure destination refuses the send is parked
at the persisted checkpoint and only the send is retried with backoff,
instead of checkpointing past a batch that was never delivered.