Skip to content

Resource: awsLambdaFunctionEventInvokeConfig

Manages an asynchronous invocation configuration for a Lambda Function or Alias. More information about asynchronous invocations and the configurable values can be found in the Lambda Developer Guide.

Example Usage

Destination Configuration

\~> NOTE: Ensure the Lambda Function IAM Role has necessary permissions for the destination, such as sqs:sendMessage or sns:publish, otherwise the API will return a generic invalidParameterValueException:TheDestinationArnArn:partition:service:region:account:resourceIsInvalid error.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.lambdaFunctionEventInvokeConfig.LambdaFunctionEventInvokeConfig(
  this,
  "example",
  {
    destinationConfig: {
      onFailure: {
        destination: "${aws_sqs_queue.example.arn}",
      },
      onSuccess: {
        destination: "${aws_sns_topic.example.arn}",
      },
    },
    functionName: "${aws_lambda_alias.example.function_name}",
  }
);

Error Handling Configuration

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.lambdaFunctionEventInvokeConfig.LambdaFunctionEventInvokeConfig(
  this,
  "example",
  {
    functionName: "${aws_lambda_alias.example.function_name}",
    maximumEventAgeInSeconds: 60,
    maximumRetryAttempts: 0,
  }
);

Configuration for Alias Name

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.lambdaFunctionEventInvokeConfig.LambdaFunctionEventInvokeConfig(
  this,
  "example",
  {
    functionName: "${aws_lambda_alias.example.function_name}",
    qualifier: "${aws_lambda_alias.example.name}",
  }
);

Configuration for Function Latest Unpublished Version

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.lambdaFunctionEventInvokeConfig.LambdaFunctionEventInvokeConfig(
  this,
  "example",
  {
    functionName: "${aws_lambda_function.example.function_name}",
    qualifier: "$LATEST",
  }
);

Configuration for Function Published Version

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.lambdaFunctionEventInvokeConfig.LambdaFunctionEventInvokeConfig(
  this,
  "example",
  {
    functionName: "${aws_lambda_function.example.function_name}",
    qualifier: "${aws_lambda_function.example.version}",
  }
);

Argument Reference

The following arguments are required:

  • functionName - (Required) Name or Amazon Resource Name (ARN) of the Lambda Function, omitting any version or alias qualifier.

The following arguments are optional:

  • destinationConfig - (Optional) Configuration block with destination configuration. See below for details.
  • maximumEventAgeInSeconds - (Optional) Maximum age of a request that Lambda sends to a function for processing in seconds. Valid values between 60 and 21600.
  • maximumRetryAttempts - (Optional) Maximum number of times to retry when the function returns an error. Valid values between 0 and 2. Defaults to 2.
  • qualifier - (Optional) Lambda Function published version, $latest, or Lambda Alias name.

destination_config Configuration Block

\~> NOTE: At least one of onFailure or onSuccess must be configured when using this configuration block, otherwise remove it completely to prevent perpetual differences in Terraform runs.

The following arguments are optional:

  • onFailure - (Optional) Configuration block with destination configuration for failed asynchronous invocations. See below for details.
  • onSuccess - (Optional) Configuration block with destination configuration for successful asynchronous invocations. See below for details.

destination_config on_failure Configuration Block

The following arguments are required:

  • destination - (Required) Amazon Resource Name (ARN) of the destination resource. See the Lambda Developer Guide for acceptable resource types and associated IAM permissions.

destination_config on_success Configuration Block

The following arguments are required:

  • destination - (Required) Amazon Resource Name (ARN) of the destination resource. See the Lambda Developer Guide for acceptable resource types and associated IAM permissions.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - Fully qualified Lambda Function name or Amazon Resource Name (ARN)

Import

Lambda Function Event Invoke Configs can be imported using the fully qualified Function name or Amazon Resource Name (ARN), e.g.,

ARN without qualifier (all versions and aliases):

$ terraform import aws_lambda_function_event_invoke_config.example arn:aws:us-east-1:123456789012:function:my_function

ARN with qualifier:

$ terraform import aws_lambda_function_event_invoke_config.example arn:aws:us-east-1:123456789012:function:my_function:production

Name without qualifier (all versions and aliases):

$ terraform import aws_lambda_function_event_invoke_config.example my_function

Name with qualifier:

$ terraform import aws_lambda_function_event_invoke_config.example my_function:production