How to trigger an AWS Mainframe Modernization batch job from Amazon EventBridge Scheduler?
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:
- You are familiar with AWS Mainframe Modernization service.
- You already have an AWS Mainframe Modernization application with batch job(s) deployed and running. [You may use the sample PlanetDemo application for testing, if you don't have an application available.]
- Note the AWS Mainframe Modernization Application Id from the AWS Console. It is the part after
app/
of the ARN. Application Id will be required later while creating the schedule.
Steps::
A. Create IAM Policy to grant access to StartBatchJob
- Login to Amazon EventBridge Scheduler Console
- Create a new IAM Policy by clicking on the Policies on the left-hand menu bar and then Create policy button.
- Select JSON in the Policy editor and paste the below statement
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "M2StartBatchJob",
"Effect": "Allow",
"Action": "m2:StartBatchJob",
"Resource": "*"
}
]
}
- Click Next and provide a Policy Name, for example
StartMainframeBatchPolicy
. - Leave rest of the values as defaults and click on Create policy button.
B. Create IAM Role
- Click on Roles on the left-hand bar menu and click Create role button.
- On the Select trusted entity page select Custom trust policy for Trusted entity type.
- 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"
}
]
}
- On the Permissions policies search window type the name of the policy created earlier, for example
StartMainframeBatchPolicy
. - Select the check box against the Policy Name and click Next.
- Provide a name to the role for example
StartMainframeBatchRole
and click Create role.
C. Create Amazon EventBridge schedule
- Switch to Amazon EventBridge Scheduler Console
- Click Create schedule button
- Provide a name to the schedule, for example
MainframeBatchSchedule
and a description (optional). - 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.
- Flexible time window invokes the target within the time window you set, thus improving the reliability of your schedule by dispersing your target invocations.
- 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.
- On the Select target page select All APIs and on the search window type
mainframe
and click on AWS Mainframe Modernization.
- 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>"
}
}
}
- Sample JSON parameters. In this example it's a AWS Blu Age application, the script name is the JCL groovy script name.
-
Click Next. On the Settings page Enable schedule.
-
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. -
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
-
The batch job will be triggered at the time set in the Amazon EventBridge Scheduler (+ within the Flexible Time window set).
-
The execution of the job can be verified by going to AWS Mainframe Modernization application and then clicking Batch jobs tab.
-
Check the Start time to validate the time of trigger.
References:
Conteúdo relevante
- AWS OFICIALAtualizada há um ano
- AWS OFICIALAtualizada há 3 anos
- AWS OFICIALAtualizada há 3 anos
- AWS OFICIALAtualizada há 3 anos