Deploy a Lambda function for Amazon IoT Events using Amazon CloudFormation - Amazon IoT Events
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

End of support notice: On May 20, 2026, Amazon will end support for Amazon IoT Events. After May 20, 2026, you will no longer be able to access the Amazon IoT Events console or Amazon IoT Events resources. For more information, see Amazon IoT Events end of support.

Deploy a Lambda function for Amazon IoT Events using Amazon CloudFormation

This tutorial uses an Amazon CloudFormation template to deploy a Lambda function. This template automatically creates an IAM role that allows the Lambda function to work with Amazon SES and Amazon SNS.

The following shows you how to use the Amazon Command Line Interface (Amazon CLI) to create a CloudFormation stack.

  1. In your device's terminal, run aws --version to check if you installed the Amazon CLI. For more information, see Installing or updating to the latest version of the Amazon CLI in the Amazon Command Line Interface User Guide.

  2. Run aws configure list to check if you configured the Amazon CLI in the Amazon Region that has all your Amazon resources for this tutorial. For more information, see Set and view configuration settings using commands in the Amazon Command Line Interface User Guide

  3. Download the CloudFormation template, notificationLambda.template.yaml.zip.

    Note

    If you have difficulty downloading the file, the template is also available in the CloudFormation template.

  4. Unzip the content and save it locally as notificationLambda.template.yaml.

  5. Open a terminal on your device and navigate to the directory where you downloaded the notificationLambda.template.yaml file.

  6. To create a CloudFormation stack, run the following command:

    aws cloudformation create-stack --stack-name notificationLambda-stack --template-body file://notificationLambda.template.yaml --capabilities CAPABILITY_IAM

You might modify this CloudFormation template to customize the Lambda function and its behavior.

Note

Amazon Lambda retries function errors twice. If the function doesn't have enough capacity to handle all incoming requests, events might wait in the queue for hours or days to be sent to the function. You can configure an undelivered-message queue (DLQ) on the function to capture events that weren't successfully processed. For more information, see Asynchronous invocation in the Amazon Lambda Developer Guide.

You can also create or configure the stack in the CloudFormation console. For more information, see Working with stacks, in the Amazon CloudFormation User Guide.