I'd like to create a number of cloudwatch alarms when specific resources are created in our AWS account (EC2 instances, ELBs, etc)
In my serverless.yml
I can do the following, but this ends up creating multiple cloudwatch rules that listen for the same event.
functions:
createLatencyAlarm:
handler: createLatencyAlarm.main
events:
- cloudwatchEvent:
event:
source:
- "aws.elasticloadbalancing"
detail-type:
- "AWS API Call via CloudTrail"
detail:
eventSource:
- "elasticloadbalancing.amazonaws.com"
eventName:
- "CreateLoadBalancer"
createUnhealthHostAlarm:
handler: createUnhealthyHostAlarm.main
events:
- cloudwatchEvent:
event:
source:
- "aws.elasticloadbalancing"
detail-type:
- "AWS API Call via CloudTrail"
detail:
eventSource:
- "elasticloadbalancing.amazonaws.com"
eventName:
- "CreateLoadBalancer"
I could also set up the events to be the same sns topic, but then I have to separately (outside of serverless) create a cloudwatch rule to listen for the event and publish to the sns topic
functions:
createLatencyAlarm:
handler: createLatencyAlarm.main
events:
- sns: create-elb
createUnhealthHostAlarm:
handler: createUnhealthyHostAlarm.main
events:
- sns: create-elb
Can I set up in serverless.yml
an event to share amongst functions?