aws-cdkaws-batch

Specifying Mount point and Volume in CDK for Batch Job [TypeScript]


I have a working StepFunction that calls a couple of Batch jobs. These were configured using the console. I'm trying to automate the deployment of the workflow using CDK (TypeScript 4.9.5). I am unable to find the options to specify the mount points and volume configuration that's found in the console.

Specifically, if you are looking at the console and setting up an EC2-based job definition: Linux and logging settings > Filesystem configuration > Additional configuration > Volumes configuration, and similarly, next to it Mount points configuration.

I am trying to do this with both aws-cdk-lib/aws-batch and @aws-cdk/aws-batch-alpha (v2.89.0), but I can't find the right properties to specify. (CDK version 2.79.0)

The Batch job is EC2-based and will run a container using a previously defined computer environments. The EBS storage cannot be restricted to 30 GB.

Update 1 - high-level code:

import * as batch from '@aws-cdk/aws-batch-alpha';

const jobdef = new batch.EcsJobDefinition(this, 'job-def-name',{
  jobDefinitionName: 'fooname',
  timeout: cdk.Duration.hours(#),
  container = new batch.EcsEc2ContainerDefinition(this, 'container-name', {
    image: fooImage,
    jobRole: batchRole,
    command: [foo, bar, baz],
    memory: cdk.Size.mebibytes(####)
    cpu: #,
    logging: ecs.LogDriver.awslogs,
  })
})

Solution

  • The AWS::Batch::JobDefinition docs indicate that CloudFormation supports EFS and host storage volumes in batch configurations.

    Correspondingly, the volumes prop of the CDK's EcsEc2ContainerDefinition construct accepts either the EfsVolume or a HostVolume options. These options appear to configure the volume and mount points.