Skip to main content

AWS Lambda

This page shows how to deploy an AWS Lambda function from an OCI artefact using the Fractal SDK.

For the artefact contract and prerequisites, see the main guide.

How the agent deploys

The Lambda offer reads sourceArtifact and picks the Lambda-native path:

  • Container image artefact → PackageType=Image, pointing Code.imageUri straight at your ECR image. No handler/runtime needed (they are baked into the image).
  • Zip artefact → the agent pulls the zip and deploys it inline (small zips) or stages it to an agent-owned S3 bucket (large zips). handler and runtime are required.

If you don't set roleArn, the agent uses the environment-provisioned Lambda execution role.

TypeScript SDK

import {AwsLambda} from '@fractal_cloud/sdk';

// Zip artefact (portable default): handler + runtime required.
const ordersFn = AwsLambda.create({
id: 'orders-fn',
version: {major: 1, minor: 0, patch: 0},
displayName: 'Orders Function',
sourceArtifact:
'123456789012.dkr.ecr.eu-central-1.amazonaws.com/orders-fn:1.4.0',
runtime: 'java21',
handler: 'com.example.Orders::handle',
memoryMb: 512,
timeoutSeconds: 30,
environment: {LOG_LEVEL: 'INFO'},
// roleArn is optional — omit to use the environment's Lambda execution role.
});

For a container-image Lambda, point sourceArtifact at an ECR image and set packageType: 'image' (or let the agent auto-detect); handler/runtime are then ignored:

const imageFn = AwsLambda.create({
id: 'orders-fn',
version: {major: 1, minor: 0, patch: 0},
displayName: 'Orders Function',
sourceArtifact:
'123456789012.dkr.ecr.eu-central-1.amazonaws.com/orders-fn:1.4.0',
packageType: 'image',
});

Satisfying a blueprint Function

When the function is declared abstractly in a blueprint, satisfy it as a Lambda and add the AWS-specific parameters:

import {Function, AwsLambda} from '@fractal_cloud/sdk';

const fn = Function.create({
id: 'orders-fn',
version: {major: 1, minor: 0, patch: 0},
displayName: 'Orders Function',
sourceArtifact:
'123456789012.dkr.ecr.eu-central-1.amazonaws.com/orders-fn:1.4.0',
runtime: 'java21',
handler: 'com.example.Orders::handle',
});

const lambda = AwsLambda.satisfy(fn.component)
.withRoleArn('arn:aws:iam::123456789012:role/orders-fn-exec')
.withMemoryMb(512)
.build();