Skip to content
v2.276.0

DurableConfig Struct ​

Configuration for durable functions.

Lambda durable functions allow for long-running executions with persistent state.

Example ​

ts
const fn = new lambda.Function(this, 'MyFunction', {
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
  durableConfig: { executionTimeout: Duration.hours(1), retentionPeriod: Duration.days(30) }, // 1 hour timeout, 30 days retention
});
python
fn = lambda_.Function(self, "MyFunction",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "lambda-handler")),
    durable_config=lambda.DurableConfig(execution_timeout=Duration.hours(1), retention_period=Duration.days(30))
)
java
Function fn = Function.Builder.create(this, "MyFunction")
        .runtime(Runtime.NODEJS_LATEST)
        .handler("index.handler")
        .code(Code.fromAsset(join(__dirname, "lambda-handler")))
        .durableConfig(DurableConfig.builder().executionTimeout(Duration.hours(1)).retentionPeriod(Duration.days(30)).build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var fn = new Function(this, "MyFunction", new FunctionProps {
    Runtime = Runtime.NODEJS_LATEST,
    Handler = "index.handler",
    Code = Code.FromAsset(Join(__dirname, "lambda-handler")),
    DurableConfig = new DurableConfig { ExecutionTimeout = Duration.Hours(1), RetentionPeriod = Duration.Days(30) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
fn := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("lambda-handler"))),
	DurableConfig: &DurableConfig{
		ExecutionTimeout: awscdk.Duration_Hours(jsii.Number(1)),
		RetentionPeriod: awscdk.Duration_Days(jsii.Number(30)),
	},
})

Properties ​

executionTimeoutDurationexecution_timeoutDurationexecutionTimeoutDurationExecutionTimeoutDurationExecutionTimeoutDurationrequired#
The amount of time that Lambda allows a durable function to run before stopping it.

Must be between 1 and 31,622,400 seconds (366 days).

retentionPeriodoptionalDurationretention_periodoptionalDurationretentionPeriodoptionalDurationRetentionPeriodoptionalDurationRetentionPeriodoptionalDuration= Duration.days(14)#
The number of days after a durable execution is closed that Lambda retains its history.

Must be between 1 and 90 days.

The underlying configuration is expressed in whole numbers of days. Providing a Duration that does not represent a whole number of days will result in a runtime or deployment error.