[英]Can I create/delete a cloudwatch event rule for an AWS lambda function from within that function?
I have a lambda function in aws that contains about 80 jobs- the jobs are triggered on a schedule by cloudwatch rules, and the lambda knows which job to run based on the parameters on those rules.我在aws中有一个lambda function,其中包含大约80个作业-这些作业是由cloudwatch规则按计划触发的,并且lambda知道基于哪些参数运行的作业。
Some jobs require new cloudwatch rules to be created programatically, and others require old rules to be deleted.有些作业需要以编程方式创建新的 cloudwatch 规则,而其他作业需要删除旧规则。
Is there a way to create/delete the cloudwatch rules that trigger a lambda entirely from within that lambda?有没有办法完全从 lambda 中创建/删除触发 lambda 的 cloudwatch 规则?
An AWS Lambda function can call any AWS API. AWS Lambda function 可以调用任何 AWS API。
To add a new Amazon CloudWatch Events rule, use:要添加新的 Amazon CloudWatch Events 规则,请使用:
put_rule()
to define a rule, then put_rule()
定义一个规则,然后put_targets()
to associate a target (eg an AWS Lambda function) with the rule put_targets()
将目标(例如 AWS Lambda 函数)与规则相关联To delete a rule, use:要删除规则,请使用:
remove_targets()
and then remove_targets()
然后delete_rule()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.