AWS Lambda scheduled event source via cloudformation

后端 未结 7 1159
猫巷女王i
猫巷女王i 2021-02-01 02:37

I already have my lambda / roles defined in cloudformation and would love to also use it to add a scheduled eventsources ... are there any docs or examples around ?

7条回答
  •  孤街浪徒
    2021-02-01 03:11

    The YAML Version

    ScheduledRule: 
      Type: AWS::Events::Rule
      Properties: 
        Description: "ScheduledRule"
        ScheduleExpression: "rate(10 minutes)"
        State: "ENABLED"
        Targets: 
          - 
            Arn: 
              Fn::GetAtt: 
                - "LambdaFunction"
                - "Arn"
            Id: "TargetFunctionV1"
    PermissionForEventsToInvokeLambda: 
      Type: AWS::Lambda::Permission
      Properties: 
        FunctionName: 
          Ref: "LambdaFunction"
        Action: "lambda:InvokeFunction"
        Principal: "events.amazonaws.com"
        SourceArn: 
          Fn::GetAtt: 
            - "ScheduledRule"
            - "Arn"
    

提交回复
热议问题