[英]How to include cloudWatch Log Group subscription in cloudFormation template?
Say I have a Log Group in cloudWatch, which I want to subscribe to a lambda with a filter (Subscriptions->Stream to AWS Lambda).假设我在 cloudWatch 中有一个日志组,我想通过过滤器(订阅->流到 AWS Lambda)订阅一个 lambda。
I want to achieve it with cloudFormation template, but from cloudFormation doc, it seems that the only two available cloudWatch resources are Alarm/Dashboard.我想用 cloudFormation 模板来实现它,但是从 cloudFormation 文档来看,似乎只有两个可用的 cloudWatch 资源是 Alarm/Dashboard。
Questions is:问题是:
Oh, that's a tricky one.哦,这是一个棘手的问题。 I only figured it out by creating one in the console and reverse enginerring - ick.
我只是通过在控制台中创建一个并逆向工程来解决这个问题 - ick。 But you're lucky - I have it on hand :P This is the json I was using for subscribing a lambda to a vpc flow log.
但是你很幸运 - 我手头有它:P 这是我用来将 lambda 订阅到 vpc 流日志的 json。
Note that the 'VPCFlowLogsGroup' is the logical Id of the log group, the 'FlowLogsCollector' that of the lambda.请注意,“VPCFlowLogsGroup”是日志组的逻辑 ID,“FlowLogsCollector”是 lambda 的逻辑 ID。
"FlowLogsCollectorEventPermission": {
"Type" : "AWS::Lambda::Permission",
"Properties" : {
"Principal" : { "Fn::Sub": "logs.${AWS::Region}.amazonaws.com" },
"Action" : "lambda:InvokeFunction",
"FunctionName" : { "Fn::GetAtt": [ "FlowLogsCollector", "Arn" ] },
"SourceAccount": { "Ref": "AWS::AccountId" },
"SourceArn" : { "Fn::GetAtt": [ "VPCFlowLogsGroup", "Arn" ] }
}
},
"FlowLogsCollectorSubscription": {
"Type" : "AWS::Logs::SubscriptionFilter",
"DependsOn": "FlowLogsCollectorEventPermission",
"Properties" : {
"LogGroupName" : { "Ref" : "VPCFlowLogsGroup" },
"FilterPattern" : "",
"DestinationArn" : { "Fn::GetAtt" : [ "FlowLogsCollector", "Arn" ] }
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.