Search code examples
aws-cloudformationamazon-cloudwatchaws-batch

troubleshoot failed cloudwatch events


This part of cloudformation template creates the event, but do not actually execute it.

  MyCWEventRule:
    Type: AWS::Events::Rule
    Properties: 
      Name: my-batch-event-rule
      ScheduleExpression: cron(01 07 ? * * *)
      State: ENABLED
      Targets: 
        - Id: my-batch-job
          Arn: !Ref Queue
          BatchParameters: 
            JobDefinition: !Ref StartJob
            JobName: tds-job
          RoleArn: !Join [ "", [!Sub "arn:aws:iam::${AWS::AccountId}:role/service-role/", !Ref ruleIAMRole]]

There are no logs to check what the problem is. If I submit the job myself using console, it works as expected. The Job Definition parameter mentioned in cron is correct as seen in this image...

enter image description here

How do I troubleshoot failed cloudwatch events?


Update:

When I click on Edit and use "Create a new role for this specific resource" it works. It means there is some problem with the line...

RoleArn: !Join [ "", [!Sub "arn:aws:iam::${AWS::AccountId}:role/service-role/", !Ref ruleIAMRole]]


Solution

  • You guessed it right! There is no need of "service-role" in the ARN role path. It should look like this...

    RoleArn: !Join [ "", [!Sub "arn:aws:iam::${AWS::AccountId}:role/", !Ref ruleIAMRole]]
    

    Or even better:

    RoleArn: !GetAtt ruleIAMRole.Arn