【问题标题】:Put custom rule in Cloudwatch events using boto3使用 boto3 将自定义规则放入 Cloudwatch 事件中
【发布时间】:2020-02-04 10:11:39
【问题描述】:

我想根据 cloudwatch 事件中添加的规则触发 lambda 函数。我在控制台中看到了一个这样的例子,

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

我想将我的 lambda 函数添​​加为目标。有没有办法使用 boto3 来做到这一点?

【问题讨论】:

标签: python-3.x amazon-web-services aws-lambda boto3 amazon-cloudwatch


【解决方案1】:

通过 boto3 调用您的 lambda 函数。见documentation

下面是例子。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-27
    • 2021-01-02
    • 2019-07-15
    • 2020-07-27
    • 1970-01-01
    • 2018-05-17
    • 2012-07-11
    相关资源
    最近更新 更多