Boto3 Lambda - Existing custom IoT Rule as event source

0

Hello forum,

We know and are able to set existing custom IoT Rule as a Trigger for AWS Lambda.

We are currently using boto3 to create lambda function.

After creating lambda function we tried to set an existing custom IoT Rule as trigger using create_event_source_mapping().

This is resulting in below error -

An error occurred (InvalidParameterValueException) when calling the CreateEventSourceMapping operation: Unrecognized event source, must be kinesis, dynamodb stream or sqs. Unsupported source arn : arn:aws:iot:xx-xx-1:xxxxxxxxxxxx:rule/ruleName

Please find the code for the same below -

import boto3
import botocore.exceptions

function_name = sample_function
trigger_arn = arn:aws:iot:xx-xx-1:xxxxxxxxxxxx:rule/ruleName

client = boto3.client('lambda')
client.create_event_source_mapping(EventSourceArn=trigger_arn,FunctionName=function_name)

Is this not supported or possible using boto3?

How to fix this?

  • Hi edgegoldberg, Did you figure out or solve this issue? I am struggling with the same error when trying to set up an IoT Rule as a trigger to a lambda function in a cloudformation template, and using the EventSourceMapping resource.

질문됨 2년 전473회 조회
1개 답변
0

Lambda event source mapping is used only for the event sources that Lambda needs to poll such as SQS, Kinesis, Kafka, etc. IoT Rules are different. In order to trigger a Lambda function from an IoT rule you need to use the create_topic_rule in the IoT client.

profile pictureAWS
전문가
Uri
답변함 2년 전
  • Hi Uri, Thank you for the response. Yes I checked that earlier and I knew that I can use create_topic_rule to create new rule and set an action to trigger lambda. But I don't think I could use create_topic_rule to set an action to trigger lambda for an already created rule. Could you please point out which API I should use for the same? (I am expecting that I just have to pass the ARN of the existing rule and ARN of the lambda)

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠