FunctionRecursionConfig class
Manages an AWS Lambda Function Recursion Config. Use this resource to control how Lambda handles recursive function invocations to prevent infinite loops.
> Note: Destruction of this resource will return the recursiveLoop configuration back to the default value of Terminate.
Example Usage
Allow Recursive Invocations
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Lambda function that may need to call itself
const example = new aws.lambda.Function("example", {
code: new pulumi.asset.FileArchive("function.zip"),
name: "recursive_processor",
role: lambdaRole.arn,
handler: "index.handler",
runtime: aws.lambda.Runtime.Python3d12,
});
// Allow the function to invoke itself recursively
const exampleFunctionRecursionConfig = new aws.lambda.FunctionRecursionConfig("example", {
functionName: example.name,
recursiveLoop: "Allow",
});
import pulumi
import pulumi_aws as aws
# Lambda function that may need to call itself
example = aws.lambda_.Function("example",
code=pulumi.FileArchive("function.zip"),
name="recursive_processor",
role=lambda_role["arn"],
handler="index.handler",
runtime=aws.lambda_.Runtime.PYTHON3D12)
# Allow the function to invoke itself recursively
example_function_recursion_config = aws.lambda_.FunctionRecursionConfig("example",
function_name=example.name,
recursive_loop="Allow")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
// Lambda function that may need to call itself
var example = new Aws.Lambda.Function("example", new()
{
Code = new FileArchive("function.zip"),
Name = "recursive_processor",
Role = lambdaRole.Arn,
Handler = "index.handler",
Runtime = Aws.Lambda.Runtime.Python3d12,
});
// Allow the function to invoke itself recursively
var exampleFunctionRecursionConfig = new Aws.Lambda.FunctionRecursionConfig("example", new()
{
FunctionName = example.Name,
RecursiveLoop = "Allow",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Lambda function that may need to call itself
example, err := lambda.NewFunction(ctx, "example", &lambda.FunctionArgs{
Code: pulumi.NewFileArchive("function.zip"),
Name: pulumi.String("recursive_processor"),
Role: pulumi.Any(lambdaRole.Arn),
Handler: pulumi.String("index.handler"),
Runtime: pulumi.String(lambda.RuntimePython3d12),
})
if err != nil {
return err
}
// Allow the function to invoke itself recursively
_, err = lambda.NewFunctionRecursionConfig(ctx, "example", &lambda.FunctionRecursionConfigArgs{
FunctionName: example.Name,
RecursiveLoop: pulumi.String("Allow"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
# Lambda function that may need to call itself
resource "aws_lambda_function" "example" {
code = fileArchive("function.zip")
name = "recursive_processor"
role = lambdaRole.arn
handler = "index.handler"
runtime = "python3.12"
}
# Allow the function to invoke itself recursively
resource "aws_lambda_functionrecursionconfig" "example" {
function_name = aws_lambda_function.example.name
recursive_loop = "Allow"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.Function;
import com.pulumi.aws.lambda.FunctionArgs;
import com.pulumi.aws.lambda.FunctionRecursionConfig;
import com.pulumi.aws.lambda.FunctionRecursionConfigArgs;
import com.pulumi.asset.FileArchive;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
// Lambda function that may need to call itself
var example = new Function("example", FunctionArgs.builder()
.code(new FileArchive("function.zip"))
.name("recursive_processor")
.role(lambdaRole.arn())
.handler("index.handler")
.runtime("python3.12")
.build());
// Allow the function to invoke itself recursively
var exampleFunctionRecursionConfig = new FunctionRecursionConfig("exampleFunctionRecursionConfig", FunctionRecursionConfigArgs.builder()
.functionName(example.name())
.recursiveLoop("Allow")
.build());
}
}
resources:
# Lambda function that may need to call itself
example:
type: aws:lambda:Function
properties:
code:
fn::fileArchive: function.zip
name: recursive_processor
role: ${lambdaRole.arn}
handler: index.handler
runtime: python3.12
# Allow the function to invoke itself recursively
exampleFunctionRecursionConfig:
type: aws:lambda:FunctionRecursionConfig
name: example
properties:
functionName: ${example.name}
recursiveLoop: Allow
Production Safety Configuration
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Production function with recursion protection
const productionProcessor = new aws.lambda.Function("production_processor", {
code: new pulumi.asset.FileArchive("processor.zip"),
name: "production-data-processor",
role: lambdaRole.arn,
handler: "app.handler",
runtime: aws.lambda.Runtime.NodeJS24dX,
tags: {
Environment: "production",
Purpose: "data-processing",
},
});
// Prevent infinite loops in production
const example = new aws.lambda.FunctionRecursionConfig("example", {
functionName: productionProcessor.name,
recursiveLoop: "Terminate",
});
import pulumi
import pulumi_aws as aws
# Production function with recursion protection
production_processor = aws.lambda_.Function("production_processor",
code=pulumi.FileArchive("processor.zip"),
name="production-data-processor",
role=lambda_role["arn"],
handler="app.handler",
runtime=aws.lambda_.Runtime.NODE_JS24D_X,
tags={
"Environment": "production",
"Purpose": "data-processing",
})
# Prevent infinite loops in production
example = aws.lambda_.FunctionRecursionConfig("example",
function_name=production_processor.name,
recursive_loop="Terminate")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
// Production function with recursion protection
var productionProcessor = new Aws.Lambda.Function("production_processor", new()
{
Code = new FileArchive("processor.zip"),
Name = "production-data-processor",
Role = lambdaRole.Arn,
Handler = "app.handler",
Runtime = Aws.Lambda.Runtime.NodeJS24dX,
Tags =
{
{ "Environment", "production" },
{ "Purpose", "data-processing" },
},
});
// Prevent infinite loops in production
var example = new Aws.Lambda.FunctionRecursionConfig("example", new()
{
FunctionName = productionProcessor.Name,
RecursiveLoop = "Terminate",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Production function with recursion protection
productionProcessor, err := lambda.NewFunction(ctx, "production_processor", &lambda.FunctionArgs{
Code: pulumi.NewFileArchive("processor.zip"),
Name: pulumi.String("production-data-processor"),
Role: pulumi.Any(lambdaRole.Arn),
Handler: pulumi.String("app.handler"),
Runtime: pulumi.String(lambda.RuntimeNodeJS24dX),
Tags: pulumi.StringMap{
"Environment": pulumi.String("production"),
"Purpose": pulumi.String("data-processing"),
},
})
if err != nil {
return err
}
// Prevent infinite loops in production
_, err = lambda.NewFunctionRecursionConfig(ctx, "example", &lambda.FunctionRecursionConfigArgs{
FunctionName: productionProcessor.Name,
RecursiveLoop: pulumi.String("Terminate"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
# Production function with recursion protection
resource "aws_lambda_function" "production_processor" {
code = fileArchive("processor.zip")
name = "production-data-processor"
role = lambdaRole.arn
handler = "app.handler"
runtime = "nodejs24.x"
tags = {
"Environment" = "production"
"Purpose" = "data-processing"
}
}
# Prevent infinite loops in production
resource "aws_lambda_functionrecursionconfig" "example" {
function_name = aws_lambda_function.production_processor.name
recursive_loop = "Terminate"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.Function;
import com.pulumi.aws.lambda.FunctionArgs;
import com.pulumi.aws.lambda.FunctionRecursionConfig;
import com.pulumi.aws.lambda.FunctionRecursionConfigArgs;
import com.pulumi.asset.FileArchive;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
// Production function with recursion protection
var productionProcessor = new Function("productionProcessor", FunctionArgs.builder()
.code(new FileArchive("processor.zip"))
.name("production-data-processor")
.role(lambdaRole.arn())
.handler("app.handler")
.runtime("nodejs24.x")
.tags(Map.ofEntries(
Map.entry("Environment", "production"),
Map.entry("Purpose", "data-processing")
))
.build());
// Prevent infinite loops in production
var example = new FunctionRecursionConfig("example", FunctionRecursionConfigArgs.builder()
.functionName(productionProcessor.name())
.recursiveLoop("Terminate")
.build());
}
}
resources:
# Production function with recursion protection
productionProcessor:
type: aws:lambda:Function
name: production_processor
properties:
code:
fn::fileArchive: processor.zip
name: production-data-processor
role: ${lambdaRole.arn}
handler: app.handler
runtime: nodejs24.x
tags:
Environment: production
Purpose: data-processing
# Prevent infinite loops in production
example:
type: aws:lambda:FunctionRecursionConfig
properties:
functionName: ${productionProcessor.name}
recursiveLoop: Terminate
Import
For backwards compatibility, the following legacy pulumi import command is also supported:
$ pulumi import aws:lambda/functionRecursionConfig:FunctionRecursionConfig example recursive_processor
Constructors
- FunctionRecursionConfig(String name, {FunctionRecursionConfigArgs? args, CustomResourceOptions? options})
-
Creates a new FunctionRecursionConfig.
nameThe Pulumi resource name.argsArguments used to configure this FunctionRecursionConfig. The set of arguments for FunctionRecursionConfig.optionsResource options controlling this resource's behavior. - FunctionRecursionConfig.reference(String urn)
- Creates a typed reference to an existing FunctionRecursionConfig resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
functionName
↔ Output<
String> -
Name of the Lambda function.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
recursiveLoop
↔ Output<
String> -
Lambda function recursion configuration. Valid values are
AlloworTerminate.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {FunctionRecursionConfigState? state, CustomResourceOptions? options}) → FunctionRecursionConfig -
Gets an existing FunctionRecursionConfig resource's state with the given
nameandid.