

# Managed AWS Mainframe Modernization integration with Control-M
<a name="aws-mainframe-modernization-managed"></a>

This section describes how Control-M integrates with and supports batch jobs that run in a managed AWS Mainframe Modernization environment deployed with a Micro Focus runtime engine. If you are implementing a custom AWS Replatform with Micro Focus environment on Amazon EC2, see the [AWS Mainframe Modernization on Amazon EC2 integration with Control-M](aws-mainframe-modernization-ec2.md) section.

This section assumes the following prerequisites:
+ An active AWS account.
+ The mainframe application is migrated and running in an AWS Replatform with Micro Focus managed runtime environment with multiple defined batch jobs.
+ For this pilot, the BankDemo example application is set up in AWS Mainframe Modernization. For setup instructions, see [Tutorial: Managed Runtime for Micro Focus](https://docs.aws.amazon.com/m2/latest/userguide/tutorial-runtime.html).

The following topics describe step-by-step setup required for integration between Control-M Scheduler and the AWS Mainframe Modernization environment for different types of integration workflows:
+ [Deploy Control-M resources](deploy-control-m-resources.md)
+ [Create a Control-M connection profile for AWS Mainframe Modernization](connection-profile.md)
+ [Create jobs and schedules in Control-M Planning](jobs-schedules-control-m.md)
+ [Monitor jobs](monitor-jobs.md)

# Deploy Control-M resources
<a name="deploy-control-m-resources"></a>

The first two steps in integrating AWS Mainframe Modernization with Control-M are to deploy the plug-in and the job type.

## Deploy the AWS Mainframe Modernization Control-M plug-in
<a name="deploy-plug-in"></a>

Plug-ins provide integration and support for the applications and services that Control-M orchestrates. For the managed AWS Mainframe Modernization service, deploy the AWS Mainframe Modernization plug-in.

The plug-in deployment is an infrequent activity. If installing the plug-in for the first time, follow the steps in the [Control-M documentation](https://docs.bmc.com/docs/ctm_integrations/control-m-for-aws-mainframe-modernization-1244652367.html). If you have an existing plug-in that you want to use, skip this step, and [create a connection profile](connection-profile.md).

## Deploy an AWS Mainframe Modernization job type in Control-M Application Integrator
<a name="deploy-job-type"></a>

The job type deployment is usually a one-time activity. If you already have an existing job type that you want to use, skip this step and move on to the next step of [creating a connection profile](connection-profile.md).

The example job type [AIJOB.ctmai](https://github.com/aws-samples/aws-mainframe-modernization-controlm-integration/blob/main/assets/AIJOB.ctmai)  is supplied in the git repository. To deploy a job type, you must perform the following steps using [Application Integrator](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Application_Integrator.htm):

1. Clone the [aws-mainframe-modernization-controlm-integration](https://github.com/aws-samples/aws-mainframe-modernization-controlm-integration) GitHub repository and download the `AIJOB.ctmai` file to a file system location that can be accessed by Application Integrator.

1. Log in to Application Integrator.

1. On the **Home** tab, select **Import job type from file**, and select the location of `AIJOB.ctmai`.

1. If you want to make any modifications to the supplied example, familiarize yourself with Application Integrator.

1. Deploy the job type by following the instructions in the [Control-M documentation](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Deploying_and_Publishing_a_Plug-in.htm).

# Create a Control-M connection profile for AWS Mainframe Modernization
<a name="connection-profile"></a>

Connection profiles define connection attributes and security credentials for a specific instance of an application. Each connection profile can be referenced by multiple jobs. You can have separate profiles for each unique combination of an application and credentials.

To [define connection profiles](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Creating_a_centralized_connection_profile.htm), you can use the graphical user interface (GUI) available in the **Configuration** domain of the Control-M Web interface, or you can use [JSON](https://docs.bmc.com/docs/automation-api/monthly/connection-profiles-1116950312.html). For information about the connection profile of the AWS Mainframe Modernization plug-in, see the [Control-M documentation](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Mainframe_Modernization_Connection_Profiles.htm#AWSMainframeModernizationConnectionProfileParameters).

The following code is an example of using JSON:

```
{
  "MANAGED-M2-REPLATFORM": {
    "Type": "ConnectionProfile:AWS Mainframe Modernization",
    "Mainframe Modernization URL": "https://m2.{{AwsRegion}}.amazonaws.com",
    "Connection Timeout": "30",
    "AWS Region": "us-west-2",
    "Authentication": "NoSecret",
    "IAM Role": "--- IAM Role name ---",
    "AWS Logs URL": "https://logs.{{AwsRegion}}.amazonaws.com",
    "Description": "",
    "Centralized": true
  }
}
```

Create a JSON file that is similar to the example, and deploy it by using the [Control-M Automation API deploy service](https://docs.bmc.com/docs/automation-api/monthly/deploy-service-1116950327.html). For example, if the JSON code is saved to a file named `cp-MANAGED-M2-REPLATFORM.json`, the `ctm` CLI syntax to deploy this connection profile is the following:

```
 ctm deploy cp-MANAGED-M2-REPLATFORM.json
```

The response from Control-M Automation API will be similar to the following:

```
[
  {
    "deploymentFile": "cp-Managed-M2-REPLATFORM.json",
    "deploymentState": "DEPLOYED_CONNECTION_PROFILES",
    "deploymentStatus": "ENDED_OK",
    "successfulFoldersCount": 0,
    "successfulSmartFoldersCount": 0,
    "successfulSubFoldersCount": 0,
    "successfulJobsCount": 0,
    "successfulConnectionProfilesCount": 1,
    "successfulDriversCount": 0,
    "isDeployDescriptorValid": false,
    "deployedConnectionProfiles": [
      "MANAGED-M2-REPLATFORM"
    ]
  }
]
```

# Create jobs and schedules in Control-M Planning
<a name="jobs-schedules-control-m"></a>

Now that you have the job type deployed and a connection profile for AWS connectivity, you can start creating and running jobs.

Each AWS Mainframe Modernization service job consists of a set of attributes, in four sections. Each section can have many attributes. The following list shows some of the more commonly used attributes.
+ General:
  + The job name
  + The application and sub-application that the job belongs to
  + The JCL to submit
  + A link to documentation
+ Scheduling:
  + Months and Days this job is eligible to run
  + Calendars such as a business accounting periods, holidays, or other special dates that cannot be defined algorithmically
  + Time windows
  + Cyclic behavior
+ Prerequisites:
  + Upstream dependencies (usually jobs, which must be completed successfully before this job becomes eligible to run)
  + Resources that might be required
  + User action that might be required
+ Actions performed by Control-M upon completion of the job:
  + Determining job success or failure (usually based on the job's completion codes, but you can override that setting to use output text or checks for a specific status)
  + Notifications, such as email, for failure or success
  + Publishing status for downstream dependencies

As with connection profiles, jobs can be created and deployed [in the GUI](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Creating_a_Job.htm) or [in JSON](https://docs.bmc.com/docs/automation-api/monthly/code-reference-1116950299.html) and deployed by using Control-M Automation API.

The following sections examine some common workflow scenarios:
+ [Initiate jobs based on the status code of previous jobs](status-code.md)
+ [Automate job runs on a scheduled frequency](scheduled.md)
+ [Base job runs on events](event-based.md)

# Initiate jobs based on the status of previous jobs
<a name="status-code"></a>

Create a flow of jobs called a workflow. Jobs in the workflow are interconnected with dependencies on successful completion of the previous jobs.

## Using the Control-M Web GUI
<a name="using-gui"></a>

To initiate a job from the Control-M user interface, do the following:

1. In the **Planning** domain, add a new **Workspace**. This opens a canvas with an empty folder object.

1. Select the AWS Mainframe Modernization job type (if you are using the supplied job type template, this is called [M2JOB](https://github.com/aws-samples/aws-mainframe-modernization-controlm-integration/blob/main/assets/AWS-jobs.json)), and drag it onto the folder.

1. After the color of the job type changes to green, drop it. The pane on the right contains the **General**, **Scheduling**, **Prerequisites**, and **Actions** sections. To create the job, see the standard instructions in the [Control-M documentation](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Creating_a_Job.htm).

1. Next, you need the **Job Name** values to configure the job types. You can find the **Job Name** values on the **Application** definition screen of the AWS Mainframe Modernization console or by running the [ListBatchJobDefinitions API](https://docs.aws.amazon.com/m2/latest/APIReference/API_ListBatchJobDefinitions.html). For this pilot, repeat steps 2–4 for several jobs, naming each one with any names you choose. Example names are `CBANK`, `CURRENCY`, I`NVFUNDS`, `BROKERAGE`, `RISKMGMT`, and `BANK-SERVICE-Managed-M2`.

1. To connect these jobs into the flow that you want, choose the condition triangle under the job object, and drag it onto the next job. For example, choose the condition triangle under `CBANK`, and drag it onto `CURRENCY`. This action makes `CBANK` the predecessor of `CURRENCY`. By default, `CBANK` must now be completed successfully before CURRENCY becomes eligible to run.

The following screenshot shows the Control-M Planning view of the basic job flow.



![\[Job flow on the left and properties on the right.\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/control-m-batch-scheduler/images/workflow-control-m-web-1.png)


*Image provided courtesy of BMC Software, Inc. ©2022*

## Using JSON
<a name="using-json"></a>

The same flow can be coded in JSON:

```
{
  "Defaults": {
    "Application": "AWSM2",
    "SubApplication": "Replatform-Managed",
    "Job": {
      "Host": "ctm-worker",
      "Output": {}
    }
  },
  "jog-managed-m2": {
    "Type": "Folder",
    "ControlmServer": "psctm",
    "OrderMethod": "Manual",
    "SiteStandard": "_z_DemoBusinessFlows",
    "CBANK": {
      "Type": "Job:AWS Mainframe Modernization",
      "ConnectionProfile": "MANAGED-M2-REPLATFORM",
      "JCL Name": "iefbr14",
      "Retrieve CloudWatch Logs": "checked",
      "Action": "Start Batch Job",
      "Application Version": "1"
    },
    "CURRENCY": {
      "Type": "Job:AWS Mainframe Modernization",
      "ConnectionProfile": "MANAGED-M2-REPLATFORM",
      "JCL Name": "iefbr14",
      "Retrieve CloudWatch Logs": "checked",
      "Action": "Start Batch Job",
      "Application Version": "1"
    },
    "BROKERAGE": {
      "Type": "Job:AWS Mainframe Modernization",
      "ConnectionProfile": "MANAGED-M2-REPLATFORM",
      "JCL Name": "iefbr14",
      "Retrieve CloudWatch Logs": "checked",
      "Action": "Start Batch Job",
      "Application Version": "1"
    },
    "INVFUNDS": {
      "Type": "Job:AWS Mainframe Modernization",
      "ConnectionProfile": "MANAGED-M2-REPLATFORM",
      "JCL Name": "iefbr14",
      "Retrieve CloudWatch Logs": "checked",
      "Action": "Start Batch Job",
      "Application Version": "1"
    },
    "RISKMGMT": {
      "Type": "Job:AWS Mainframe Modernization",
      "ConnectionProfile": "MANAGED-M2-REPLATFORM",
      "JCL Name": "iefbr14",
      "Retrieve CloudWatch Logs": "checked",
      "Action": "Start Batch Job",
      "Application Version": "1"
    },
    "BANK-SERVICE-Managed-M2": {
      "Type": "Job:SLAManagement",
      "ServiceName": "Bank Service - Managed M2",
      "RunAs": "ctmagent",
      "CompleteBy": {
        "Time": "12:00",
        "Days": "0"
      }
    },
    "leftbranch": {
      "Type": "Flow",
      "Sequence": [
        "CURRENCY",
        "RISKMGMT",
        "BANK-SERVICE-Managed-M2"
      ]
    },
    "middlebranch": {
      "Type": "Flow",
      "Sequence": [
        "CBANK",
        "CURRENCY",
        "INVFUNDS",
        "BANK-SERVICE-Managed-M2"
      ]
    },
    "rightbranch": {
      "Type": "Flow",
      "Sequence": [
        "CURRENCY",
        "BROKERAGE",
        "BANK-SERVICE-Managed-M2"
      ]
    }
  }
}
```

To deploy this flow, use the deploy service:

```
ctm deploy folder-MANAGED-M2-REPLATFORM.json
```

# Automate job runs on a scheduled frequency
<a name="scheduled"></a>

Using the flow that you created in the previous steps, you can add basic and runtime scheduling.
+ Basic scheduling defines which days a job can run (for example, every weekday, only on working days, month end, or quarter end).
+ Runtime scheduling determines when a job will run on the day that it's eligible to run (for example, every hour, after specified resources are available, or only after manual confirmation).

You can set the basic and runtime scheduling on the **Scheduling** tab.

# Base job runs on events
<a name="event-based"></a>

Control-M Managed File Transfer (MFT) is an FTP/SFTP client and server that you can use to watch and transfer files between a local host and a remote host. For more information about defining a File Transfer job, see the [Control-M documentation](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/File_Transfer_Job.htm).

This pilot uses the File Transfer job to watch for a file-creation event of a file with the .poc extension in the `/bmcfile`  folder in an S3 bucket named `bmc-poc-bucket`. When that event occurs, the Control-M job is initiated to run the next job. You can optionally pass the full path, including the bucket name.

# Monitor jobs
<a name="monitor-jobs"></a>

You can monitor and validate the processing of jobs within the Control-M Monitoring domain and through the AWS Management Console, ensuring comprehensive observation and verification across both these platforms.

## Control-M Monitoring
<a name="control-m-monitoring"></a>

Job submissions and runs can be monitored in the *Control-M Monitoring domain.* By default, AWS Mainframe Modernization service jobs will appear together with all other Control-M work. If you want to see only the AWS Mainframe Modernization service jobs without any other workload (or any other filtering requirements), you can create a *Viewpoint*.

Viewpoints show not only job information but also relationships with upstream and downstream dependencies. Additionally, if your workflow includes AWS Mainframe Modernization and other Control-M job types, you can see and manage the entire flow in the Monitoring domain.

To follow detailed steps, see the [Viewpoints section of Monitoring](https://documents.bmc.com/supportu/9.0.21/en-US/Documentation/Viewpoints.htm) in the Control-M documentation.

The following screenshot shows the outputs of two workflows. On the left side, the workflow is completed successfully with all jobs in green. On the right side, the workflow is only partially successful because job `CURRRENCY` returned the **Failed** status, which is indicated by the red color. The workflow stopped there, leaving the remaining jobs in the **Wait Schedule** state.



![\[Diagrams of workflows on the left, job properties on the right.\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/control-m-batch-scheduler/images/monitor-jobs.png)


*Image provided courtesy of BMC Software, Inc. ©2022*

## Monitoring on the console
<a name="console"></a>

To view job and log information on AWS, sign in to the AWS Management Console, and then navigate to the [AWS Mainframe Modernization console](https://console.aws.amazon.com/m2/home?region=us-east-1#/applications). 



![\[Jobs and statuses listed on the AWS Mainframe Modernization console.\]](http://docs.aws.amazon.com/prescriptive-guidance/latest/control-m-batch-scheduler/images/monitor-jobs-aws-management-console.png)


This view doesn't include dependencies nor any workload that isn't managed by the AWS Mainframe Modernization service.