1
votes

I want to trigger a lambda function based on rule added in cloudwatch event. I saw an example of doing it in console like this,

{
    "detail-type": [
        "Glue Crawler State Change"
    ],
    "source": [
        "aws.glue"
    ],
    "detail": {
        "crawlerName": [
            "MyTestCrawl"
        ],
        "state": [
            "Succeeded"
        ]
    }
}

I want to add my lambda function as target. Is there a way to do it using boto3?

1
Would you like to run lambda with cron expression from rule? May be this would help, boto3.amazonaws.com/v1/documentation/api/latest/reference/…Sajeer Noohukannu

1 Answers

-1
votes

Invoke your lambda function through boto3. See the documentation

Below is the example.

response = client.invoke(
    ClientContext='MyApp',
    FunctionName='MyFunction',
    InvocationType='Event',
    LogType='Tail',
    Payload='fileb://file-path/input.json',
    Qualifier='1',
)