Skip to main content

CloudWatch Events

create and delete rule

$ aws events list-rules
$ aws events put-rule --name testrule --schedule-expression "rate(60 minutes)"  --state DISABLED
$ aws events enable-rule --name testrule
$ aws events disable-rule --name testrule
$ aws events delete-rule --name testrule
$ aws events describe-rule --name testrule

create and remove targets

$ aws events put-targets --rule testrule --targets '{"Input":"{\"interval\":60,\"rss\":\"https://status.aws.amazon.com/rss/ec2-ap-northeast-1.rss\",\"topicarn\":\"arn:aws:sns:ap-northeast-1:xxxxxxxxxxxx:mysnstopic\"}","Id":"1","Arn":"arn:aws:lambda:ap-northeast-1:xxxxxxxxxxxx:function:mylambdafunction"}'
$ aws events remove-targets --rule testrule --ids 1
$ aws events list-targets-by-rule --rule testrule

CloudFormation stack template sample

EventsRuleRssNotify:
  Type: 'AWS::Events::Rule'
  Properties:
    Description: 'rss notification'
    Name: rssnotifycf
    ScheduleExpression: 'rate(15 minutes)'
    State: ENABLED
    Targets:
      - Arn: !GetAtt LambdaRssNotification.Arn
        Id: "1"
        Input: !Ref INPUTJSON