How to trigger an AWS Mainframe Modernization batch job from Amazon EventBridge Scheduler?

5 minute read
Content level: Advanced
2

This article explains how Amazon EventBridge Scheduler can be used to trigger an AWS Mainframe Modernization batch job either one-time or in a recurring schedule.

Overview

Amazon EventBridge Scheduler is a serverless scheduler that allows you to create, run, and manage tasks at any time without having to provision or manage underlying infrastructure. It supports multiple scheduling formats, such as cron, fixed rate, one-time, or time window. EventBridge Scheduler can easily integrate with AWS Mainframe Modernization service and can trigger batch jobs following the configured schedule pattern.

Assumptions:

Application Id


Steps::

A. Create IAM Policy to grant access to StartBatchJob

  1. Login to Amazon EventBridge Scheduler Console
  2. Create a new IAM Policy by clicking on the Policies on the left-hand menu bar and then Create policy button.
  3. Select JSON in the Policy editor and paste the below statement
{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "M2StartBatchJob",
			"Effect": "Allow",
			"Action": "m2:StartBatchJob",
			"Resource": "*"
		}
	]
}
  1. Click Next and provide a Policy Name, for example StartMainframeBatchPolicy.
  2. Leave rest of the values as defaults and click on Create policy button.

B. Create IAM Role

  1. Click on Roles on the left-hand bar menu and click Create role button.
  2. On the Select trusted entity page select Custom trust policy for Trusted entity type.
  3. On the Custom trust policy window paste the below statement and click Next.
{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "Statement1",
			"Effect": "Allow",
			"Principal": {
				"Service": "scheduler.amazonaws.com"
			},
			"Action": "sts:AssumeRole"
		}
	]
}
  1. On the Permissions policies search window type the name of the policy created earlier, for example StartMainframeBatchPolicy.
  2. Select the check box against the Policy Name and click Next.
  3. Provide a name to the role for example StartMainframeBatchRole and click Create role.

C. Create Amazon EventBridge schedule

  1. Switch to Amazon EventBridge Scheduler Console
  2. Click Create schedule button
  3. Provide a name to the schedule, for example MainframeBatchSchedule and a description (optional).
  4. On the Schedule pattern you may select One-time schedule if you want to schedule the batch job to run one-time. Select a Date and Time when you want the job to run. In this case we will select the Recurring schedule with Schedule type as Cron-based schedule. To set the batch job to be triggered everyday at 6AM EST, the Cron expression will be set as below.

Cron expression

  1. Flexible time window invokes the target within the time window you set, thus improving the reliability of your schedule by dispersing your target invocations.
  2. In the Timeframe window, set the Time zone you want. You may specify a Start date and time and/or End date and time if required. Click Next.

Time Frame

  1. On the Select target page select All APIs and on the search window type mainframe and click on AWS Mainframe Modernization.

Select Target

  1. On the Find API search box type startbatchjob and select AWS Mainframe Modernization StartBatchJob. This will open the JSON parameter window. Paste the below content and replace the <application_id> with the actual value of the Application Id of the AWS Mainframe Modernization Application (noted earlier) and the <script_name> with the JCL script name you want to schedule.
{
  "ApplicationId": "<application_id>",
  "BatchJobIdentifier": {
      "ScriptBatchJobIdentifier": {
          "ScriptName": "<script_name>"
      }
  }
}
  1. Sample JSON parameters. In this example it's a AWS Blu Age application, the script name is the JCL groovy script name.

Sample JSON

  1. Click Next. On the Settings page Enable schedule. Enable Schedule

  2. There are various features to explore and apply as required. On the Permissions section choose Use existing role and then select StartMainframeBatchRole role created earlier. Click Next. Select Role

  3. Review the schedule details and click Create schedule. A green banner will appear at the top if the schedule is created successfully.

D. Verify batch Job execution

  1. The batch job will be triggered at the time set in the Amazon EventBridge Scheduler (+ within the Flexible Time window set).

  2. The execution of the job can be verified by going to AWS Mainframe Modernization application and then clicking Batch jobs tab. Verify Batch Run

  3. Check the Start time to validate the time of trigger.


References: