AwsLambdaExecutionModule
Hierarchy
- AModule<AwsLambdaExecutionModuleSchema, Execution>
- AwsLambdaExecutionModule
Index
Constructors
Properties
Methods
Resources
Constructors
constructor
Parameters
moduleId: string
The ID this module is loaded under.
Returns AwsLambdaExecutionModule
Properties
readonlyinheritedmoduleId
The ID this module was loaded under. It scopes everything the module produces, so the same module class can be loaded more than once.
staticreadonlyinheritedMODULE_PACKAGE
The package the module is registered under, set by Module.
staticreadonlyinheritedMODULE_SCHEMA
The schema of the module's inputs, set by Module.
Methods
onInit
Creates the execution, checks its deployment has what Lambda needs, and joins it to the image, buckets and tables it uses.
Parameters
inputs: AwsLambdaExecutionModuleSchema
Returns Promise<(AwsLambdaExecution | AwsLambdaExecutionOverlay)[]>
inheritedregisterHooks
To hook custom behavior into Octo's lifecycle for the duration of this module. Override it to return the callbacks you want run.
Returns { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }
optionalpostCommitHooks?: PostHookSignature[]
optionalpostModelActionHooks?: PostHookSignature[]
optionalpostResourceActionHooks?: PostHookSignature[]
optionalpreCommitHooks?: PreHookSignature[]
optionalpreModelActionHooks?: PreHookSignature[]
optionalpreResourceActionHooks?: PreHookSignature[]
registerMetadata
Resolves the account and the AWS region this execution runs in.
Parameters
inputs: AwsLambdaExecutionModuleSchema
Returns Promise<{ awsAccountId: string; awsRegionId: string }>
AwsLambdaExecutionModuleruns a deployment's container image as a Lambda function in a serverless region, behind a function URL, with itsenvironmentVariables,reservedConcurrencyandinvokeMode; its memory, timeout and command come from the deployment.The server and the deployment create nothing; this module creates everything Lambda needs to run them: an IAM role trusting Lambda and holding the server's grants, the function, and a URL that only signed requests may call. The role gets no permission to write logs.
The function runs outside a VPC, so it ignores the server's security group rules. The deployment must name an image octo publishes into ECR, set a memory from 128 to 10240 MiB and a timeout from 1 to 900 seconds, and listen on at most one tcp port. A deployment that does not is rejected before anything is created. The function runs on the processor the image is published for, and the Lambda Web Adapter forwards each request to the deployment's port, as
AWS_LWA_PORT.Lambda bills each request (about $0.20 per million) and the memory held for as long as each runs (about $0.0000167 per GB-second on x86_64, about a fifth less on arm64), after a free million requests and 400,000 GB-seconds a month. An idle function costs nothing. Its logs bill about $0.50 per GB written to CloudWatch.
None for a new deployment or setting: Lambda swaps the code in place, and requests already running finish on the old code. A request arriving after the function was idle waits for a cold start, from a fraction of a second to a few seconds for a container image.
TypeScript
Modules/Execution/AwsLambdaExecution
A request runs for at most 900 seconds, and at most 60 behind
AwsCloudFrontServiceModule. Memory is 128 to 10,240 MiB. ABUFFEREDrequest or response is at most 6 MB;RESPONSE_STREAMstreams a larger response.Every function of the account in a region shares one concurrency quota, 1,000 requests at once by default and lower on a new account;
reservedConcurrencysets part of it aside for this function, and caps it there.The function runs outside a VPC: it cannot reach a private subnet, an EFS filesystem or anything else inside one, and the server's security group rules do not apply to it.
It serves only through a function URL, one request and one response at a time: no websockets and no connection the server keeps open to push to a client. An app that will need live updates polls, or runs on an execution that serves connections, such as
AwsEcsExecutionModule.The function URL accepts only signed requests (
AWS_IAM), so the function is reached throughAwsCloudFrontServiceModuleor by a caller that signs its requests, never anonymously.The log group
/aws/lambda/<executionId>must not exist before the first apply, which fails otherwise.The function writes its logs as plain text, never as JSON.
Nothing: a function holds no data. Its logs are kept for
logRetentionInDaysand deleted with it.Moving the function to another account or region replaces it, and its URL. Every other change, a new image included, updates it in place.
Executionmodel.