LoginSignup
0
0

More than 5 years have passed since last update.

serverless framework

Last updated at Posted at 2016-11-24

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:
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0