# InvocationType

The invocation type to apply to a trigger.

This determines whether the trigger function should await the result of the to be triggered function or not.

- Source: [`triggers/lib/trigger.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/triggers/lib/trigger.ts#L68)
- Type last changed: v2.73.0 · 6 Apr 2023

## Example

TypeScript:

```ts
import * as triggers from 'aws-cdk-lib/triggers';

const func = new lambda.Function(this, 'MyFunction', {
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_LATEST,
  code: lambda.Code.fromInline('foo'),
});

new triggers.Trigger(this, 'MyTrigger', {
  handler: func,
  timeout: Duration.minutes(10),
  invocationType: triggers.InvocationType.EVENT,
});
```

Python:

```python
import aws_cdk.triggers as triggers

func = lambda_.Function(self, "MyFunction",
    handler="index.handler",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    code=lambda_.Code.from_inline("foo")
)

triggers.Trigger(self, "MyTrigger",
    handler=func,
    timeout=Duration.minutes(10),
    invocation_type=triggers.InvocationType.EVENT
)
```

Java:

```java
import software.amazon.awscdk.triggers.*;

Function func = Function.Builder.create(this, "MyFunction")
        .handler("index.handler")
        .runtime(Runtime.NODEJS_LATEST)
        .code(Code.fromInline("foo"))
        .build();

Trigger.Builder.create(this, "MyTrigger")
        .handler(func)
        .timeout(Duration.minutes(10))
        .invocationType(InvocationType.EVENT)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.Triggers;

var func = new Function(this, "MyFunction", new FunctionProps {
    Handler = "index.handler",
    Runtime = Runtime.NODEJS_LATEST,
    Code = Code.FromInline("foo")
});

new Trigger(this, "MyTrigger", new TriggerProps {
    Handler = func,
    Timeout = Duration.Minutes(10),
    InvocationType = InvocationType.EVENT
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"

func := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
	Handler: jsii.String("index.handler"),
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Code: lambda.Code_FromInline(jsii.String("foo")),
})

triggers.NewTrigger(this, jsii.String("MyTrigger"), &TriggerProps{
	Handler: func,
	Timeout: awscdk.Duration_Minutes(jsii.Number(10)),
	InvocationType: triggers.InvocationType_EVENT,
})
```

## Members

| Member | Description |
| --- | --- |
| `EVENT` | Invoke the function asynchronously. |
| `REQUEST_RESPONSE` | Invoke the function synchronously. |
| `DRY_RUN` | Validate parameter values and verify that the user or role has permission to invoke the function. |

## Referenced by

- [`TriggerProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.triggers.TriggerProps.html).invocationType
