Add AWS Event rules (not schedule)
serverless.yml
resources:
Resources:
RuleTest:
Type: AWS::Events::Rule
Properties:
EventPattern:
{
"source": [
"aws.ec2"
],
"detail-type": [
"EC2 Instance State-change Notification"
],
"detail": {
"state": [
"running"
]
}
}
Name: test-rule
Targets:
-
Arn:
Fn::GetAtt:
- "HelloLambdaFunction"
- "Arn"
Id: "TargetFunctionV1"
PermissionForEventsToInvokeLambda:
Type: "AWS::Lambda::Permission"
Properties:
FunctionName:
Ref: "LambdaFunction"
Action: "lambda:InvokeFunction"
Principal: "events.amazonaws.com"
SourceArn:
Fn::GetAtt:
- "RuleTest"
- "Arn"
Look!
Arn:
Fn::GetAtt:
- "HelloLambdaFunction"
- "Arn"
HelloLambdaFunction
named by serverless.yml
's this part.
functions:
hello: