# RecursiveLoop

- Source: [`aws-lambda/lib/function.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-lambda/lib/function.ts#L161)
- Type last changed: v2.153.0 · 20 Aug 2024

## Example

TypeScript:

```ts
const fn = new lambda.Function(this, 'MyFunction', {
  code: lambda.Code.fromAsset(path.join(__dirname, 'handler.zip')),
  runtime: lambda.Runtime.JAVA_11,
  handler: 'example.Handler::handleRequest',
  recursiveLoop: lambda.RecursiveLoop.TERMINATE,
  });
```

Python:

```python
fn = lambda_.Function(self, "MyFunction",
    code=lambda_.Code.from_asset(path.join(__dirname, "handler.zip")),
    runtime=lambda_.Runtime.JAVA_11,
    handler="example.Handler::handleRequest",
    recursive_loop=lambda_.RecursiveLoop.TERMINATE
)
```

Java:

```java
Function fn = Function.Builder.create(this, "MyFunction")
        .code(Code.fromAsset(join(__dirname, "handler.zip")))
        .runtime(Runtime.JAVA_11)
        .handler("example.Handler::handleRequest")
        .recursiveLoop(RecursiveLoop.TERMINATE)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var fn = new Function(this, "MyFunction", new FunctionProps {
    Code = Code.FromAsset(Join(__dirname, "handler.zip")),
    Runtime = Runtime.JAVA_11,
    Handler = "example.Handler::handleRequest",
    RecursiveLoop = RecursiveLoop.TERMINATE
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
fn := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
	Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("handler.zip"))),
	Runtime: lambda.Runtime_JAVA_11(),
	Handler: jsii.String("example.Handler::handleRequest"),
	RecursiveLoop: lambda.RecursiveLoop_TERMINATE,
})
```

## Members

| Member | Description |
| --- | --- |
| `ALLOW` | Allows the recursive loop to happen and does not terminate it. |
| `TERMINATE` | Terminates the recursive loop. |

## Referenced by

- [`FunctionOptions`](/v2/docs/aws-cdk-lib.aws_lambda.FunctionOptions).recursiveLoop
