lko*_*lko 1 serverless amazon-cloudwatch-events
无服务器不会创建 CloudWatch Events 作为 lambda 的触发器。没有警告或错误。
functions:
aggregate:
handler: statistics.handler
events:
- schedule:
rate: rate(10 minutes)
Run Code Online (Sandbox Code Playgroud)
无服务器的示例并未展示缩进的关键性质。https://serverless.com/framework/docs/providers/aws/events/schedule/#schedule
functions:
aggregate:
handler: statistics.handler
events:
# "- schedule:" has to start at the same indentation as the "events:" above it.
- schedule:
# The CloudWatch Events Rules have to be exactly 4 spaces indented below the "- schedule:"
rate: rate(10 minutes)
# ... other fields
Run Code Online (Sandbox Code Playgroud)
关键:
- schedule:与其events:上方对齐。rate: rate(6 minutes)从缩进的 4 个空格- schedule:示例代码:
service: my-service
provider:
name: aws
region: us-west-2
runtime: nodejs10.x
functions:
hello:
handler: handler.hello
events:
- schedule:
rate: cron(*/5 * * * ? *)
enabled: true
Run Code Online (Sandbox Code Playgroud)
和
module.exports.hello = (event, context, callback) => {
console.log("Hello, world!");
callback(null);
};
Run Code Online (Sandbox Code Playgroud)
简单地缩进 - 像我期望的那样安排 2 个空格不会在 AWS 中创建 cloudwatch 事件。2 个空格的单一更改决定了是否创建了 cloudwatch 事件规则。
注意:两个缩进之间不会抛出任何错误,但它会创建 6 对 8 AWS 资源(缺少 2 个不创建 cloudwatch 事件规则)。
| 归档时间: |
|
| 查看次数: |
716 次 |
| 最近记录: |