Search code examples
amazon-web-serviceseventsrules

Ability to specify unique parameters in an Amazon CloudWatch Events rule


Is it possible to have parameters to AWS::Events::Rule ? Lets you have different scheduled rules that runs the same code but you want a parameter as input so that you can differentiate which rule that was triggered?

  ScheduledRule1:
    Type: AWS::Events::Rule
    Properties:
      Description: Scheduled Rule
      ScheduleExpression: "rate(5 minutes)"
      State: "ENABLED"
      Targets:
        - Id: "MyJob"
          Arn: !GetAtt MyJob.Arn

  ScheduledRule2:
    Type: AWS::Events::Rule
    Properties:
      Description: Scheduled Rule
      ScheduleExpression: "rate(60 minutes)"
      State: "ENABLED"
      Targets:
        - Id: "MyJob"
          Arn: !GetAtt MyJob.Arn

Solution

  • Yes.

    When specifying a target, you can provide a constant to help identify which rule triggered the AWS Lambda function.

    Here it is in the Amazon CloudWatch Events console:

    CloudWatch Events

    In CloudFormation, this would be set via the Input parameter in the Target section.