mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
2.3 KiB
2.3 KiB
Read this on the main serverless docs site
CloudWatch Event
Simple event definition
This will enable your Lambda function to be called by an EC2 event rule. Please check the page of Event Types for CloudWatch Events.
functions:
myCloudWatch:
handler: myCloudWatch.handler
events:
- cloudwatchEvent:
event:
source:
- "aws.ec2"
detail-type:
- "EC2 Instance State-change Notification"
detail:
state:
- pending
Enabling / Disabling
Note: cloudwatchEvent events are enabled by default.
This will create and attach a disabled cloudwatchEvent event for the myCloudWatch function.
functions:
myCloudWatch:
handler: myCloudWatch.handler
events:
- cloudwatchEvent:
event:
source:
- "aws.ec2"
detail-type:
- "EC2 Instance State-change Notification"
detail:
state:
- pending
enabled: false
Specify Input or Inputpath
You can specify input values to the Lambda function.
functions:
myCloudWatch:
handler: myCloudWatch.handler
events:
- cloudwatchEvent:
event:
source:
- "aws.ec2"
detail-type:
- "EC2 Instance State-change Notification"
detail:
state:
- pending
input:
key1: value1
key2: value2
stageParams:
stage: dev
- cloudwatchEvent:
event:
source:
- "aws.ec2"
detail-type:
- "EC2 Instance State-change Notification"
detail:
state:
- pending
inputPath: '$.stageVariables'