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.

TypeScript SDK​

A function is split across the two levels like every other component. The blueprint declares an abstract Function and governs the vendor-neutral parameters; the Live System selects the AwsLambda offer and supplies the AWS-specific ones.

1. Declare the Function in the blueprint​

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

export const fractal = createFractal({
id: 'orders',
version: {major: 1, minor: 0, patch: 0},
description: 'Orders processing function.',
boundedContextId: {
ownerType: 'Personal',
ownerId: process.env['OWNER_ID']!,
name: 'reusable-templates',
},
blueprint: bp => {
const orders = bp.add(
Function({id: 'orders-fn', displayName: 'Orders Function'})
.withRuntime('java21') // guardrail
.withMemory(512) // guardrail: MB
.withTimeout(30) // guardrail: seconds
.withEnvironment({LOG_LEVEL: 'INFO'}),
);
return {orders};
},
operations: s => ({
/** The artefact the application ships. */
withArtifact: (uri: string) => s.orders.set('sourceArtifact', uri),
}),
});

withRuntime, withMemory, withTimeout, withConcurrency and withEnvironment are vendor-neutral and identical on every cloud — the same blueprint satisfies an Azure Function or a Cloud Run function without editing.

2. Select the Lambda offer in the Live System​

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

const liveSystem = fractal
.specialize()
.withArtifact('123456789012.dkr.ecr.eu-central-1.amazonaws.com/orders-fn:1.4.0')
.toLiveSystem({
name: 'orders-dev',
environment,
select: {
'orders-fn': AwsLambda({
region: 'eu-central-1',
handler: 'com.example.Orders::handle',
roleArn: 'arn:aws:iam::123456789012:role/orders-fn-exec',
}),
},
});

handler and roleArn are AWS concepts, so they live on the offer, not the component — a blueprint carrying them could never be satisfied by another vendor.

For a container-image Lambda, point the artefact at an ECR image instead of a zip — nothing else changes. The agent detects the package type from the artefact, and for an image it takes the handler and runtime from the image itself rather than from the parameters.

handler and roleArn are both required by the offer

The offer's type requires them even for an image artefact, where handler is then unused. If you want the environment-provisioned Lambda execution role rather than your own, that is not expressible today — roleArn has no optional form.

See the Component Reference for every parameter the offer accepts, and Core API for the authoring surface.