[英]How can I trigger a lambda when a log group is created in cloudwatch?
How can I trigger a lambda when a log group is created in cloudwatch?在 cloudwatch 中创建日志组时,如何触发 lambda? What I am thinking the easiest way to do is to create a cloudwatch rule to send cloudtrail event to lambda. Is it reasonable to do?
我认为最简单的方法是创建一个 cloudwatch 规则,将 cloudtrail 事件发送到 lambda。这样做合理吗? If yes, how can I filter out other events but only trigger lambda when a log group is created?
如果是,如何过滤掉其他事件,只在创建日志组时触发 lambda?
The only event type supported by CloudWatch Events (CWE) for CW Logs (CWL) is: CloudWatch Events (CWE) for CW Logs (CWL) 支持的唯一事件类型是:
AWS API Call via CloudTrail
Therefore, you can catch the events of interests when you enabled CloudTrail (CT) trail .因此,您可以在启用CloudTrail (CT) trail时捕获感兴趣的事件。 Once enable, API events would be available in CWE.
一旦启用,API 个事件将在 CWE 中可用。 Then, you would have to create CWE rule which captures CreateLogGroup API call.
然后,您必须创建捕获CreateLogGroup API 调用的 CWE 规则。 The rule would trigger your lambda function.
该规则将触发您的 lambda function。
An example CWE rule could be:一个示例 CWE 规则可以是:
{
"source": [
"aws.logs"
],
"detail-type": [
"AWS API Call via CloudTrail"
],
"detail": {
"eventSource": [
"logs.amazonaws.com"
],
"eventName": [
"CreateLogGroup"
]
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.