awscdkawsbatchalpha

package module
v2.0.0-rc.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

AWS Batch Construct Library


All classes with the Cfn prefix in this module (CFN Resources) are always stable and safe to use.

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


This module is part of the AWS Cloud Development Kit project.

AWS Batch is a batch processing tool for efficiently running hundreds of thousands computing jobs in AWS. Batch can dynamically provision different types of compute resources based on the resource requirements of submitted jobs.

AWS Batch simplifies the planning, scheduling, and executions of your batch workloads across a full range of compute services like Amazon EC2 and Spot Resources.

Batch achieves this by utilizing queue processing of batch job requests. To successfully submit a job for execution, you need the following resources:

  1. Job Definition - Group various job properties (container image, resource requirements, env variables...) into a single definition. These definitions are used at job submission time.
  2. Compute Environment - the execution runtime of submitted batch jobs
  3. Job Queue - the queue where batch jobs can be submitted to via AWS SDK/CLI

For more information on AWS Batch visit the AWS Docs for Batch.

Compute Environment

At the core of AWS Batch is the compute environment. All batch jobs are processed within a compute environment, which uses resource like OnDemand/Spot EC2 instances or Fargate.

In MANAGED mode, AWS will handle the provisioning of compute resources to accommodate the demand. Otherwise, in UNMANAGED mode, you will need to manage the provisioning of those resources.

Below is an example of each available type of compute environment:

const defaultVpc = new ec2.Vpc(this, 'VPC');

// default is managed
const awsManagedEnvironment = new batch.ComputeEnvironment(stack, 'AWS-Managed-Compute-Env', {
  computeResources: {
    vpc
  }
});

const customerManagedEnvironment = new batch.ComputeEnvironment(stack, 'Customer-Managed-Compute-Env', {
  managed: false // unmanaged environment
});
Spot-Based Compute Environment

It is possible to have AWS Batch submit spotfleet requests for obtaining compute resources. Below is an example of how this can be done:

const vpc = new ec2.Vpc(this, 'VPC');

const spotEnvironment = new batch.ComputeEnvironment(stack, 'MySpotEnvironment', {
  computeResources: {
    type: batch.ComputeResourceType.SPOT,
    bidPercentage: 75, // Bids for resources at 75% of the on-demand price
    vpc,
  },
});
Fargate Compute Environment

It is possible to have AWS Batch submit jobs to be run on Fargate compute resources. Below is an example of how this can be done:

const vpc = new ec2.Vpc(this, 'VPC');

const fargateSpotEnvironment = new batch.ComputeEnvironment(stack, 'MyFargateEnvironment', {
  computeResources: {
    type: batch.ComputeResourceType.FARGATE_SPOT,
    vpc,
  },
});
Understanding Progressive Allocation Strategies

AWS Batch uses an allocation strategy to determine what compute resource will efficiently handle incoming job requests. By default, BEST_FIT will pick an available compute instance based on vCPU requirements. If none exist, the job will wait until resources become available. However, with this strategy, you may have jobs waiting in the queue unnecessarily despite having more powerful instances available. Below is an example of how that situation might look like:

Compute Environment:

1. m5.xlarge => 4 vCPU
2. m5.2xlarge => 8 vCPU
Job Queue:
---------
| A | B |
---------

Job Requirements:
A => 4 vCPU - ALLOCATED TO m5.xlarge
B => 2 vCPU - WAITING

In this situation, Batch will allocate Job A to compute resource #1 because it is the most cost efficient resource that matches the vCPU requirement. However, with this BEST_FIT strategy, Job B will not be allocated to our other available compute resource even though it is strong enough to handle it. Instead, it will wait until the first job is finished processing or wait a similar m5.xlarge resource to be provisioned.

The alternative would be to use the BEST_FIT_PROGRESSIVE strategy in order for the remaining job to be handled in larger containers regardless of vCPU requirement and costs.

Launch template support

Simply define your Launch Template:

const myLaunchTemplate = new ec2.CfnLaunchTemplate(this, 'LaunchTemplate', {
  launchTemplateName: 'extra-storage-template',
  launchTemplateData: {
    blockDeviceMappings: [
      {
        deviceName: '/dev/xvdcz',
        ebs: {
          encrypted: true,
          volumeSize: 100,
          volumeType: 'gp2'
        }
      }
    ]
  }
});

and use it:

const myComputeEnv = new batch.ComputeEnvironment(this, 'ComputeEnv', {
  computeResources: {
    launchTemplate: {
      launchTemplateName: myLaunchTemplate.launchTemplateName as string, //or simply use an existing template name
    },
    vpc,
  },
  computeEnvironmentName: 'MyStorageCapableComputeEnvironment',
});
Importing an existing Compute Environment

To import an existing batch compute environment, call ComputeEnvironment.fromComputeEnvironmentArn().

Below is an example:

const computeEnv = batch.ComputeEnvironment.fromComputeEnvironmentArn(this, 'imported-compute-env', 'arn:aws:batch:us-east-1:555555555555:compute-environment/My-Compute-Env');
Change the baseline AMI of the compute resources

Occasionally, you will need to deviate from the default processing AMI.

ECS Optimized Amazon Linux 2 example:

const myComputeEnv = new batch.ComputeEnvironment(this, 'ComputeEnv', {
  computeResources: {
    image: new ecs.EcsOptimizedAmi({
      generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
    }),
    vpc,
  }
});

Custom based AMI example:

const myComputeEnv = new batch.ComputeEnvironment(this, 'ComputeEnv', {
  computeResources: {
    image: ec2.MachineImage.genericLinux({
      "[aws-region]": "[ami-ID]",
    })
    vpc,
  }
});

Job Queue

Jobs are always submitted to a specific queue. This means that you have to create a queue before you can start submitting jobs. Each queue is mapped to at least one (and no more than three) compute environment. When the job is scheduled for execution, AWS Batch will select the compute environment based on ordinal priority and available capacity in each environment.

const jobQueue = new batch.JobQueue(stack, 'JobQueue', {
  computeEnvironments: [
    {
      // Defines a collection of compute resources to handle assigned batch jobs
      computeEnvironment,
      // Order determines the allocation order for jobs (i.e. Lower means higher preference for job assignment)
      order: 1,
    },
  ],
});
Priorty-Based Queue Example

Sometimes you might have jobs that are more important than others, and when submitted, should take precedence over the existing jobs. To achieve this, you can create a priority based execution strategy, by assigning each queue its own priority:

const highPrioQueue = new batch.JobQueue(stack, 'JobQueue', {
  computeEnvironments: sharedComputeEnvs,
  priority: 2,
});

const lowPrioQueue = new batch.JobQueue(stack, 'JobQueue', {
  computeEnvironments: sharedComputeEnvs,
  priority: 1,
});

By making sure to use the same compute environments between both job queues, we will give precedence to the highPrioQueue for the assigning of jobs to available compute environments.

Importing an existing Job Queue

To import an existing batch job queue, call JobQueue.fromJobQueueArn().

Below is an example:

const jobQueue = batch.JobQueue.fromJobQueueArn(this, 'imported-job-queue', 'arn:aws:batch:us-east-1:555555555555:job-queue/High-Prio-Queue');

Job Definition

A Batch Job definition helps AWS Batch understand important details about how to run your application in the scope of a Batch Job. This involves key information like resource requirements, what containers to run, how the compute environment should be prepared, and more. Below is a simple example of how to create a job definition:

const repo = ecr.Repository.fromRepositoryName(stack, 'batch-job-repo', 'todo-list');

new batch.JobDefinition(stack, 'batch-job-def-from-ecr', {
  container: {
    image: new ecs.EcrImage(repo, 'latest'),
  },
});
Using a local Docker project

Below is an example of how you can create a Batch Job Definition from a local Docker application.

new batch.JobDefinition(stack, 'batch-job-def-from-local', {
  container: {
    // todo-list is a directory containing a Dockerfile to build the application
    image: ecs.ContainerImage.fromAsset('../todo-list'),
  },
});
Providing custom log configuration

You can provide custom log driver and its configuration for the container.

new batch.JobDefinition(stack, 'job-def', {
  container: {
    image: ecs.EcrImage.fromRegistry('docker/whalesay'),
    logConfiguration: {
      logDriver: batch.LogDriver.AWSLOGS,
      options: { 'awslogs-region': 'us-east-1' },
      secretOptions: [
        batch.ExposedSecret.fromParametersStore('xyz', ssm.StringParameter.fromStringParameterName(stack, 'parameter', 'xyz')),
      ],
    },
  },
});
Importing an existing Job Definition
From ARN

To import an existing batch job definition from its ARN, call JobDefinition.fromJobDefinitionArn().

Below is an example:

const job = batch.JobDefinition.fromJobDefinitionArn(this, 'imported-job-definition', 'arn:aws:batch:us-east-1:555555555555:job-definition/my-job-definition');
From Name

To import an existing batch job definition from its name, call JobDefinition.fromJobDefinitionName(). If name is specified without a revision then the latest active revision is used.

Below is an example:

// Without revision
const job = batch.JobDefinition.fromJobDefinitionName(this, 'imported-job-definition', 'my-job-definition');

// With revision
const job = batch.JobDefinition.fromJobDefinitionName(this, 'imported-job-definition', 'my-job-definition:3');

Documentation

Overview

The CDK Construct Library for AWS::Batch

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeEnvironment_IsConstruct

func ComputeEnvironment_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead

func ComputeEnvironment_IsResource

func ComputeEnvironment_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource. Experimental.

func JobDefinition_IsConstruct

func JobDefinition_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead

func JobDefinition_IsResource

func JobDefinition_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource. Experimental.

func JobQueue_IsConstruct

func JobQueue_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead

func JobQueue_IsResource

func JobQueue_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource. Experimental.

func NewComputeEnvironment_Override

func NewComputeEnvironment_Override(c ComputeEnvironment, scope constructs.Construct, id *string, props *ComputeEnvironmentProps)

Experimental.

func NewExposedSecret_Override

func NewExposedSecret_Override(e ExposedSecret, optionName *string, secretArn *string)

Experimental.

func NewJobDefinition_Override

func NewJobDefinition_Override(j JobDefinition, scope constructs.Construct, id *string, props *JobDefinitionProps)

Experimental.

func NewJobQueue_Override

func NewJobQueue_Override(j JobQueue, scope constructs.Construct, id *string, props *JobQueueProps)

Experimental.

Types

type AllocationStrategy

type AllocationStrategy string

Properties for how to prepare compute resources that are provisioned for a compute environment. Experimental.

const (
	AllocationStrategy_BEST_FIT                AllocationStrategy = "BEST_FIT"
	AllocationStrategy_BEST_FIT_PROGRESSIVE    AllocationStrategy = "BEST_FIT_PROGRESSIVE"
	AllocationStrategy_SPOT_CAPACITY_OPTIMIZED AllocationStrategy = "SPOT_CAPACITY_OPTIMIZED"
)

type ComputeEnvironment

type ComputeEnvironment interface {
	awscdk.Resource
	IComputeEnvironment
	ComputeEnvironmentArn() *string
	ComputeEnvironmentName() *string
	Env() *awscdk.ResourceEnvironment
	Node() constructs.Node
	PhysicalName() *string
	Stack() awscdk.Stack
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	GeneratePhysicalName() *string
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	GetResourceNameAttribute(nameAttr *string) *string
	ToString() *string
}

Batch Compute Environment.

Defines a batch compute environment to run batch jobs on. Experimental.

func NewComputeEnvironment

func NewComputeEnvironment(scope constructs.Construct, id *string, props *ComputeEnvironmentProps) ComputeEnvironment

Experimental.

type ComputeEnvironmentProps

type ComputeEnvironmentProps struct {
	// A name for the compute environment.
	//
	// Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.
	// Experimental.
	ComputeEnvironmentName *string `json:"computeEnvironmentName"`
	// The details of the required compute resources for the managed compute environment.
	//
	// If specified, and this is an unmanaged compute environment, will throw an error.
	//
	// By default, AWS Batch managed compute environments use a recent, approved version of the
	// Amazon ECS-optimized AMI for compute resources.
	// Experimental.
	ComputeResources *ComputeResources `json:"computeResources"`
	// The state of the compute environment.
	//
	// If the state is set to true, then the compute
	// environment accepts jobs from a queue and can scale out automatically based on queues.
	// Experimental.
	Enabled *bool `json:"enabled"`
	// Determines if AWS should manage the allocation of compute resources for processing jobs.
	//
	// If set to false, then you are in charge of providing the compute resource details.
	// Experimental.
	Managed *bool `json:"managed"`
	// The IAM role used by Batch to make calls to other AWS services on your behalf for managing the resources that you use with the service.
	//
	// By default, this role is created for you using
	// the AWS managed service policy for Batch.
	// Experimental.
	ServiceRole awsiam.IRole `json:"serviceRole"`
}

Properties for creating a new Compute Environment. Experimental.

type ComputeResourceType

type ComputeResourceType string

Property to specify if the compute environment uses On-Demand, SpotFleet, Fargate, or Fargate Spot compute resources. Experimental.

const (
	ComputeResourceType_ON_DEMAND    ComputeResourceType = "ON_DEMAND"
	ComputeResourceType_SPOT         ComputeResourceType = "SPOT"
	ComputeResourceType_FARGATE      ComputeResourceType = "FARGATE"
	ComputeResourceType_FARGATE_SPOT ComputeResourceType = "FARGATE_SPOT"
)

type ComputeResources

type ComputeResources struct {
	// The VPC network that all compute resources will be connected to.
	// Experimental.
	Vpc awsec2.IVpc `json:"vpc"`
	// The allocation strategy to use for the compute resource in case not enough instances of the best fitting instance type can be allocated.
	//
	// This could be due to availability of the instance type in
	// the region or Amazon EC2 service limits. If this is not specified, the default for the EC2
	// ComputeResourceType is BEST_FIT, which will use only the best fitting instance type, waiting for
	// additional capacity if it's not available. This allocation strategy keeps costs lower but can limit
	// scaling. If you are using Spot Fleets with BEST_FIT then the Spot Fleet IAM Role must be specified.
	// BEST_FIT_PROGRESSIVE will select an additional instance type that is large enough to meet the
	// requirements of the jobs in the queue, with a preference for an instance type with a lower cost.
	// The default value for the SPOT instance type is SPOT_CAPACITY_OPTIMIZED, which is only available for
	// for this type of compute resources and will select an additional instance type that is large enough
	// to meet the requirements of the jobs in the queue, with a preference for an instance type that is
	// less likely to be interrupted.
	// Experimental.
	AllocationStrategy AllocationStrategy `json:"allocationStrategy"`
	// This property will be ignored if you set the environment type to ON_DEMAND.
	//
	// The maximum percentage that a Spot Instance price can be when compared with the On-Demand price for
	// that instance type before instances are launched. For example, if your maximum percentage is 20%,
	// then the Spot price must be below 20% of the current On-Demand price for that EC2 instance. You always
	// pay the lowest (market) price and never more than your maximum percentage. If you leave this field empty,
	// the default value is 100% of the On-Demand price.
	// Experimental.
	BidPercentage *float64 `json:"bidPercentage"`
	// Key-value pair tags to be applied to resources that are launched in the compute environment.
	//
	// For AWS Batch, these take the form of "String1": "String2", where String1 is the tag key and
	// String2 is the tag value—for example, { "Name": "AWS Batch Instance - C4OnDemand" }.
	// Experimental.
	ComputeResourcesTags *map[string]*string `json:"computeResourcesTags"`
	// The desired number of EC2 vCPUS in the compute environment.
	// Experimental.
	DesiredvCpus *float64 `json:"desiredvCpus"`
	// The EC2 key pair that is used for instances launched in the compute environment.
	//
	// If no key is defined, then SSH access is not allowed to provisioned compute resources.
	// Experimental.
	Ec2KeyPair *string `json:"ec2KeyPair"`
	// The Amazon Machine Image (AMI) ID used for instances launched in the compute environment.
	// Experimental.
	Image awsec2.IMachineImage `json:"image"`
	// The Amazon ECS instance profile applied to Amazon EC2 instances in a compute environment.
	//
	// You can specify
	// the short name or full Amazon Resource Name (ARN) of an instance profile. For example, ecsInstanceRole or
	// arn:aws:iam::<aws_account_id>:instance-profile/ecsInstanceRole . For more information, see Amazon ECS
	// Instance Role in the AWS Batch User Guide.
	// Experimental.
	InstanceRole *string `json:"instanceRole"`
	// The types of EC2 instances that may be launched in the compute environment.
	//
	// You can specify instance
	// families to launch any instance type within those families (for example, c4 or p3), or you can specify
	// specific sizes within a family (such as c4.8xlarge). You can also choose optimal to pick instance types
	// (from the C, M, and R instance families) on the fly that match the demand of your job queues.
	// Experimental.
	InstanceTypes *[]awsec2.InstanceType `json:"instanceTypes"`
	// An optional launch template to associate with your compute resources.
	//
	// For more information, see README file.
	// Experimental.
	LaunchTemplate *LaunchTemplateSpecification `json:"launchTemplate"`
	// The maximum number of EC2 vCPUs that an environment can reach.
	//
	// Each vCPU is equivalent to
	// 1,024 CPU shares. You must specify at least one vCPU.
	// Experimental.
	MaxvCpus *float64 `json:"maxvCpus"`
	// The minimum number of EC2 vCPUs that an environment should maintain (even if the compute environment state is DISABLED).
	//
	// Each vCPU is equivalent to 1,024 CPU shares. By keeping this set to 0 you will not have instance time wasted when
	// there is no work to be run. If you set this above zero you will maintain that number of vCPUs at all times.
	// Experimental.
	MinvCpus *float64 `json:"minvCpus"`
	// The Amazon EC2 placement group to associate with your compute resources.
	// Experimental.
	PlacementGroup *string `json:"placementGroup"`
	// The EC2 security group(s) associated with instances launched in the compute environment.
	// Experimental.
	SecurityGroups *[]awsec2.ISecurityGroup `json:"securityGroups"`
	// This property will be ignored if you set the environment type to ON_DEMAND.
	//
	// The Amazon Resource Name (ARN) of the Amazon EC2 Spot Fleet IAM role applied to a SPOT compute environment.
	// For more information, see Amazon EC2 Spot Fleet Role in the AWS Batch User Guide.
	// Experimental.
	SpotFleetRole awsiam.IRole `json:"spotFleetRole"`
	// The type of compute environment: ON_DEMAND, SPOT, FARGATE, or FARGATE_SPOT.
	// Experimental.
	Type ComputeResourceType `json:"type"`
	// The VPC subnets into which the compute resources are launched.
	// Experimental.
	VpcSubnets *awsec2.SubnetSelection `json:"vpcSubnets"`
}

Properties for defining the structure of the batch compute cluster. Experimental.

type ExposedSecret

type ExposedSecret interface {
	OptionName() *string
	SetOptionName(val *string)
	SecretArn() *string
	SetSecretArn(val *string)
}

Exposed secret for log configuration. Experimental.

func ExposedSecret_FromParametersStore

func ExposedSecret_FromParametersStore(optionName *string, parameter awsssm.IParameter) ExposedSecret

User Parameters Store Parameter. Experimental.

func ExposedSecret_FromSecretsManager

func ExposedSecret_FromSecretsManager(optionName *string, secret awssecretsmanager.ISecret) ExposedSecret

Use Secrets Manager Secret. Experimental.

func NewExposedSecret

func NewExposedSecret(optionName *string, secretArn *string) ExposedSecret

Experimental.

type IComputeEnvironment

type IComputeEnvironment interface {
	awscdk.IResource
	// The ARN of this compute environment.
	// Experimental.
	ComputeEnvironmentArn() *string
	// The name of this compute environment.
	// Experimental.
	ComputeEnvironmentName() *string
}

Properties of a compute environment. Experimental.

func ComputeEnvironment_FromComputeEnvironmentArn

func ComputeEnvironment_FromComputeEnvironmentArn(scope constructs.Construct, id *string, computeEnvironmentArn *string) IComputeEnvironment

Fetches an existing batch compute environment by its amazon resource name. Experimental.

type IJobDefinition

type IJobDefinition interface {
	awscdk.IResource
	// The ARN of this batch job definition.
	// Experimental.
	JobDefinitionArn() *string
	// The name of the batch job definition.
	// Experimental.
	JobDefinitionName() *string
}

An interface representing a job definition - either a new one, created with the CDK, *using the {@link JobDefinition} class, or existing ones, referenced using the {@link JobDefinition.fromJobDefinitionArn} method. Experimental.

func JobDefinition_FromJobDefinitionArn

func JobDefinition_FromJobDefinitionArn(scope constructs.Construct, id *string, jobDefinitionArn *string) IJobDefinition

Imports an existing batch job definition by its amazon resource name. Experimental.

func JobDefinition_FromJobDefinitionName

func JobDefinition_FromJobDefinitionName(scope constructs.Construct, id *string, jobDefinitionName *string) IJobDefinition

Imports an existing batch job definition by its name.

If name is specified without a revision then the latest active revision is used. Experimental.

type IJobQueue

type IJobQueue interface {
	awscdk.IResource
	// The ARN of this batch job queue.
	// Experimental.
	JobQueueArn() *string
	// A name for the job queue.
	//
	// Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.
	// Experimental.
	JobQueueName() *string
}

Properties of a Job Queue. Experimental.

func JobQueue_FromJobQueueArn

func JobQueue_FromJobQueueArn(scope constructs.Construct, id *string, jobQueueArn *string) IJobQueue

Fetches an existing batch job queue by its amazon resource name. Experimental.

type IMultiNodeProps

type IMultiNodeProps interface {
	// The number of nodes associated with a multi-node parallel job.
	// Experimental.
	Count() *float64
	// The number of nodes associated with a multi-node parallel job.
	// Experimental.
	SetCount(c *float64)
	// Specifies the node index for the main node of a multi-node parallel job.
	//
	// This node index value must be fewer than the number of nodes.
	// Experimental.
	MainNode() *float64
	// Specifies the node index for the main node of a multi-node parallel job.
	//
	// This node index value must be fewer than the number of nodes.
	// Experimental.
	SetMainNode(m *float64)
	// A list of node ranges and their properties associated with a multi-node parallel job.
	// Experimental.
	RangeProps() *[]INodeRangeProps
	// A list of node ranges and their properties associated with a multi-node parallel job.
	// Experimental.
	SetRangeProps(r *[]INodeRangeProps)
}

Properties for specifying multi-node properties for compute resources. Experimental.

type INodeRangeProps

type INodeRangeProps interface {
	// The container details for the node range.
	// Experimental.
	Container() *JobDefinitionContainer
	// The container details for the node range.
	// Experimental.
	SetContainer(c *JobDefinitionContainer)
	// The minimum node index value to apply this container definition against.
	//
	// You may nest node ranges, for example 0:10 and 4:5, in which case the 4:5 range properties override the 0:10 properties.
	// Experimental.
	FromNodeIndex() *float64
	// The minimum node index value to apply this container definition against.
	//
	// You may nest node ranges, for example 0:10 and 4:5, in which case the 4:5 range properties override the 0:10 properties.
	// Experimental.
	SetFromNodeIndex(f *float64)
	// The maximum node index value to apply this container definition against. If omitted, the highest value is used relative.
	//
	// to the number of nodes associated with the job. You may nest node ranges, for example 0:10 and 4:5,
	// in which case the 4:5 range properties override the 0:10 properties.
	// Experimental.
	ToNodeIndex() *float64
	// The maximum node index value to apply this container definition against. If omitted, the highest value is used relative.
	//
	// to the number of nodes associated with the job. You may nest node ranges, for example 0:10 and 4:5,
	// in which case the 4:5 range properties override the 0:10 properties.
	// Experimental.
	SetToNodeIndex(t *float64)
}

Properties for a multi-node batch job. Experimental.

type JobDefinition

type JobDefinition interface {
	awscdk.Resource
	IJobDefinition
	Env() *awscdk.ResourceEnvironment
	JobDefinitionArn() *string
	JobDefinitionName() *string
	Node() constructs.Node
	PhysicalName() *string
	Stack() awscdk.Stack
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	GeneratePhysicalName() *string
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	GetResourceNameAttribute(nameAttr *string) *string
	ToString() *string
}

Batch Job Definition.

Defines a batch job definition to execute a specific batch job. Experimental.

func NewJobDefinition

func NewJobDefinition(scope constructs.Construct, id *string, props *JobDefinitionProps) JobDefinition

Experimental.

type JobDefinitionContainer

type JobDefinitionContainer struct {
	// The image used to start a container.
	// Experimental.
	Image awsecs.ContainerImage `json:"image"`
	// Whether or not to assign a public IP to the job.
	// Experimental.
	AssignPublicIp *bool `json:"assignPublicIp"`
	// The command that is passed to the container.
	//
	// If you provide a shell command as a single string, you have to quote command-line arguments.
	// Experimental.
	Command *[]*string `json:"command"`
	// The environment variables to pass to the container.
	// Experimental.
	Environment *map[string]*string `json:"environment"`
	// The IAM role that AWS Batch can assume.
	//
	// Required when using Fargate.
	// Experimental.
	ExecutionRole awsiam.IRole `json:"executionRole"`
	// The number of physical GPUs to reserve for the container.
	//
	// The number of GPUs reserved for all
	// containers in a job should not exceed the number of available GPUs on the compute resource that the job is launched on.
	// Experimental.
	GpuCount *float64 `json:"gpuCount"`
	// The instance type to use for a multi-node parallel job.
	//
	// Currently all node groups in a
	// multi-node parallel job must use the same instance type. This parameter is not valid
	// for single-node container jobs.
	// Experimental.
	InstanceType awsec2.InstanceType `json:"instanceType"`
	// The IAM role that the container can assume for AWS permissions.
	// Experimental.
	JobRole awsiam.IRole `json:"jobRole"`
	// Linux-specific modifications that are applied to the container, such as details for device mappings.
	//
	// For now, only the `devices` property is supported.
	// Experimental.
	LinuxParams awsecs.LinuxParameters `json:"linuxParams"`
	// The log configuration specification for the container.
	// Experimental.
	LogConfiguration *LogConfiguration `json:"logConfiguration"`
	// The hard limit (in MiB) of memory to present to the container.
	//
	// If your container attempts to exceed
	// the memory specified here, the container is killed. You must specify at least 4 MiB of memory for EC2 and 512 MiB for Fargate.
	// Experimental.
	MemoryLimitMiB *float64 `json:"memoryLimitMiB"`
	// The mount points for data volumes in your container.
	// Experimental.
	MountPoints *[]*awsecs.MountPoint `json:"mountPoints"`
	// Fargate platform version.
	// Experimental.
	PlatformVersion awsecs.FargatePlatformVersion `json:"platformVersion"`
	// When this parameter is true, the container is given elevated privileges on the host container instance (similar to the root user).
	// Experimental.
	Privileged *bool `json:"privileged"`
	// When this parameter is true, the container is given read-only access to its root file system.
	// Experimental.
	ReadOnly *bool `json:"readOnly"`
	// A list of ulimits to set in the container.
	// Experimental.
	Ulimits *[]*awsecs.Ulimit `json:"ulimits"`
	// The user name to use inside the container.
	// Experimental.
	User *string `json:"user"`
	// The number of vCPUs reserved for the container.
	//
	// Each vCPU is equivalent to
	// 1,024 CPU shares. You must specify at least one vCPU for EC2 and 0.25 for Fargate.
	// Experimental.
	Vcpus *float64 `json:"vcpus"`
	// A list of data volumes used in a job.
	// Experimental.
	Volumes *[]*awsecs.Volume `json:"volumes"`
}

Properties of a job definition container. Experimental.

type JobDefinitionProps

type JobDefinitionProps struct {
	// An object with various properties specific to container-based jobs.
	// Experimental.
	Container *JobDefinitionContainer `json:"container"`
	// The name of the job definition.
	//
	// Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.
	// Experimental.
	JobDefinitionName *string `json:"jobDefinitionName"`
	// An object with various properties specific to multi-node parallel jobs.
	// Experimental.
	NodeProps IMultiNodeProps `json:"nodeProps"`
	// When you submit a job, you can specify parameters that should replace the placeholders or override the default job definition parameters.
	//
	// Parameters
	// in job submission requests take precedence over the defaults in a job definition.
	// This allows you to use the same job definition for multiple jobs that use the same
	// format, and programmatically change values in the command at submission time.
	// Experimental.
	Parameters *map[string]*string `json:"parameters"`
	// The platform capabilities required by the job definition.
	// Experimental.
	PlatformCapabilities *[]PlatformCapabilities `json:"platformCapabilities"`
	// The number of times to move a job to the RUNNABLE status.
	//
	// You may specify between 1 and
	// 10 attempts. If the value of attempts is greater than one, the job is retried on failure
	// the same number of attempts as the value.
	// Experimental.
	RetryAttempts *float64 `json:"retryAttempts"`
	// The timeout configuration for jobs that are submitted with this job definition.
	//
	// You can specify
	// a timeout duration after which AWS Batch terminates your jobs if they have not finished.
	// Experimental.
	Timeout awscdk.Duration `json:"timeout"`
}

Construction properties of the {@link JobDefinition} construct. Experimental.

type JobQueue

type JobQueue interface {
	awscdk.Resource
	IJobQueue
	Env() *awscdk.ResourceEnvironment
	JobQueueArn() *string
	JobQueueName() *string
	Node() constructs.Node
	PhysicalName() *string
	Stack() awscdk.Stack
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	GeneratePhysicalName() *string
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	GetResourceNameAttribute(nameAttr *string) *string
	ToString() *string
}

Batch Job Queue.

Defines a batch job queue to define how submitted batch jobs should be ran based on specified batch compute environments. Experimental.

func NewJobQueue

func NewJobQueue(scope constructs.Construct, id *string, props *JobQueueProps) JobQueue

Experimental.

type JobQueueComputeEnvironment

type JobQueueComputeEnvironment struct {
	// The batch compute environment to use for processing submitted jobs to this queue.
	// Experimental.
	ComputeEnvironment IComputeEnvironment `json:"computeEnvironment"`
	// The order in which this compute environment will be selected for dynamic allocation of resources to process submitted jobs.
	// Experimental.
	Order *float64 `json:"order"`
}

Properties for mapping a compute environment to a job queue. Experimental.

type JobQueueProps

type JobQueueProps struct {
	// The set of compute environments mapped to a job queue and their order relative to each other.
	//
	// The job scheduler uses this parameter to
	// determine which compute environment should execute a given job. Compute environments must be in the VALID state before you can associate them
	// with a job queue. You can associate up to three compute environments with a job queue.
	// Experimental.
	ComputeEnvironments *[]*JobQueueComputeEnvironment `json:"computeEnvironments"`
	// The state of the job queue.
	//
	// If set to true, it is able to accept jobs.
	// Experimental.
	Enabled *bool `json:"enabled"`
	// A name for the job queue.
	//
	// Up to 128 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed.
	// Experimental.
	JobQueueName *string `json:"jobQueueName"`
	// The priority of the job queue.
	//
	// Job queues with a higher priority (or a higher integer value for the priority parameter) are evaluated first
	// when associated with the same compute environment. Priority is determined in descending order, for example, a job queue with a priority value
	// of 10 is given scheduling preference over a job queue with a priority value of 1.
	// Experimental.
	Priority *float64 `json:"priority"`
}

Properties of a batch job queue. Experimental.

type LaunchTemplateSpecification

type LaunchTemplateSpecification struct {
	// The Launch template name.
	// Experimental.
	LaunchTemplateName *string `json:"launchTemplateName"`
	// The launch template version to be used (optional).
	// Experimental.
	Version *string `json:"version"`
}

Launch template property specification. Experimental.

type LogConfiguration

type LogConfiguration struct {
	// The log driver to use for the container.
	// Experimental.
	LogDriver LogDriver `json:"logDriver"`
	// The configuration options to send to the log driver.
	// Experimental.
	Options interface{} `json:"options"`
	// The secrets to pass to the log configuration as options.
	//
	// For more information, see https://docs.aws.amazon.com/batch/latest/userguide/specifying-sensitive-data-secrets.html#secrets-logconfig
	// Experimental.
	SecretOptions *[]ExposedSecret `json:"secretOptions"`
}

Log configuration options to send to a custom log driver for the container. Experimental.

type LogDriver

type LogDriver string

The log driver to use for the container. Experimental.

const (
	LogDriver_AWSLOGS    LogDriver = "AWSLOGS"
	LogDriver_FLUENTD    LogDriver = "FLUENTD"
	LogDriver_GELF       LogDriver = "GELF"
	LogDriver_JOURNALD   LogDriver = "JOURNALD"
	LogDriver_LOGENTRIES LogDriver = "LOGENTRIES"
	LogDriver_JSON_FILE  LogDriver = "JSON_FILE"
	LogDriver_SPLUNK     LogDriver = "SPLUNK"
	LogDriver_SYSLOG     LogDriver = "SYSLOG"
)

type PlatformCapabilities

type PlatformCapabilities string

Platform capabilities. Experimental.

const (
	PlatformCapabilities_EC2     PlatformCapabilities = "EC2"
	PlatformCapabilities_FARGATE PlatformCapabilities = "FARGATE"
)

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL