1. Packages
  2. AWS
  3. API Docs
  4. lambda
  5. FunctionRecursionConfig
AWS v7.2.0 published on Thursday, Jul 31, 2025 by Pulumi

aws.lambda.FunctionRecursionConfig

Explore with Pulumi AI

aws logo
AWS v7.2.0 published on Thursday, Jul 31, 2025 by Pulumi

    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 recursive_loop 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")
    
    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
    	})
    }
    
    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 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.List;
    import java.util.ArrayList;
    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.NodeJS20dX,
        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_JS20D_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")
    
    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.RuntimeNodeJS20dX),
    			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
    	})
    }
    
    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.NodeJS20dX,
            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 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.List;
    import java.util.ArrayList;
    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("nodejs20.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: nodejs20.x
          tags:
            Environment: production
            Purpose: data-processing
      # Prevent infinite loops in production
      example:
        type: aws:lambda:FunctionRecursionConfig
        properties:
          functionName: ${productionProcessor.name}
          recursiveLoop: Terminate
    

    Create FunctionRecursionConfig Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new FunctionRecursionConfig(name: string, args: FunctionRecursionConfigArgs, opts?: CustomResourceOptions);
    @overload
    def FunctionRecursionConfig(resource_name: str,
                                args: FunctionRecursionConfigArgs,
                                opts: Optional[ResourceOptions] = None)
    
    @overload
    def FunctionRecursionConfig(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                function_name: Optional[str] = None,
                                recursive_loop: Optional[str] = None,
                                region: Optional[str] = None)
    func NewFunctionRecursionConfig(ctx *Context, name string, args FunctionRecursionConfigArgs, opts ...ResourceOption) (*FunctionRecursionConfig, error)
    public FunctionRecursionConfig(string name, FunctionRecursionConfigArgs args, CustomResourceOptions? opts = null)
    public FunctionRecursionConfig(String name, FunctionRecursionConfigArgs args)
    public FunctionRecursionConfig(String name, FunctionRecursionConfigArgs args, CustomResourceOptions options)
    
    type: aws:lambda:FunctionRecursionConfig
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args FunctionRecursionConfigArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args FunctionRecursionConfigArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args FunctionRecursionConfigArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FunctionRecursionConfigArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args FunctionRecursionConfigArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var functionRecursionConfigResource = new Aws.Lambda.FunctionRecursionConfig("functionRecursionConfigResource", new()
    {
        FunctionName = "string",
        RecursiveLoop = "string",
        Region = "string",
    });
    
    example, err := lambda.NewFunctionRecursionConfig(ctx, "functionRecursionConfigResource", &lambda.FunctionRecursionConfigArgs{
    	FunctionName:  pulumi.String("string"),
    	RecursiveLoop: pulumi.String("string"),
    	Region:        pulumi.String("string"),
    })
    
    var functionRecursionConfigResource = new FunctionRecursionConfig("functionRecursionConfigResource", FunctionRecursionConfigArgs.builder()
        .functionName("string")
        .recursiveLoop("string")
        .region("string")
        .build());
    
    function_recursion_config_resource = aws.lambda_.FunctionRecursionConfig("functionRecursionConfigResource",
        function_name="string",
        recursive_loop="string",
        region="string")
    
    const functionRecursionConfigResource = new aws.lambda.FunctionRecursionConfig("functionRecursionConfigResource", {
        functionName: "string",
        recursiveLoop: "string",
        region: "string",
    });
    
    type: aws:lambda:FunctionRecursionConfig
    properties:
        functionName: string
        recursiveLoop: string
        region: string
    

    FunctionRecursionConfig Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The FunctionRecursionConfig resource accepts the following input properties:

    FunctionName string
    Name of the Lambda function.
    RecursiveLoop string

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    FunctionName string
    Name of the Lambda function.
    RecursiveLoop string

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    functionName String
    Name of the Lambda function.
    recursiveLoop String

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    functionName string
    Name of the Lambda function.
    recursiveLoop string

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    function_name str
    Name of the Lambda function.
    recursive_loop str

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    region str
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    functionName String
    Name of the Lambda function.
    recursiveLoop String

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the FunctionRecursionConfig resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing FunctionRecursionConfig Resource

    Get an existing FunctionRecursionConfig resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: FunctionRecursionConfigState, opts?: CustomResourceOptions): FunctionRecursionConfig
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            function_name: Optional[str] = None,
            recursive_loop: Optional[str] = None,
            region: Optional[str] = None) -> FunctionRecursionConfig
    func GetFunctionRecursionConfig(ctx *Context, name string, id IDInput, state *FunctionRecursionConfigState, opts ...ResourceOption) (*FunctionRecursionConfig, error)
    public static FunctionRecursionConfig Get(string name, Input<string> id, FunctionRecursionConfigState? state, CustomResourceOptions? opts = null)
    public static FunctionRecursionConfig get(String name, Output<String> id, FunctionRecursionConfigState state, CustomResourceOptions options)
    resources:  _:    type: aws:lambda:FunctionRecursionConfig    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    FunctionName string
    Name of the Lambda function.
    RecursiveLoop string

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    FunctionName string
    Name of the Lambda function.
    RecursiveLoop string

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    functionName String
    Name of the Lambda function.
    recursiveLoop String

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    functionName string
    Name of the Lambda function.
    recursiveLoop string

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    function_name str
    Name of the Lambda function.
    recursive_loop str

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    region str
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    functionName String
    Name of the Lambda function.
    recursiveLoop String

    Lambda function recursion configuration. Valid values are Allow or Terminate.

    The following arguments are optional:

    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.

    Import

    For backwards compatibility, the following legacy pulumi import command is also supported:

    $ pulumi import aws:lambda/functionRecursionConfig:FunctionRecursionConfig example recursive_processor
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v7.2.0 published on Thursday, Jul 31, 2025 by Pulumi