BatchJobProps Struct
Customize the Batch Job Event Target.
Example
ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as batch from 'aws-cdk-lib/aws-batch';
import { ContainerImage } from 'aws-cdk-lib/aws-ecs';
declare const vpc: ec2.Vpc;
const computeEnvironment = new batch.FargateComputeEnvironment(this, 'ComputeEnv', {
vpc,
});
const jobQueue = new batch.JobQueue(this, 'JobQueue', {
priority: 1,
computeEnvironments: [
{
computeEnvironment,
order: 1,
},
],
});
const jobDefinition = new batch.EcsJobDefinition(this, 'MyJob', {
container: new batch.EcsEc2ContainerDefinition(this, 'Container', {
image: ecs.ContainerImage.fromRegistry('test-repo'),
memory: cdk.Size.mebibytes(2048),
cpu: 256,
}),
});
const queue = new sqs.Queue(this, 'Queue');
const rule = new events.Rule(this, 'Rule', {
schedule: events.Schedule.rate(Duration.hours(1)),
});
rule.addTarget(new targets.BatchJob(
jobQueue.jobQueueArn,
jobQueue,
jobDefinition.jobDefinitionArn,
jobDefinition,
{
deadLetterQueue: queue,
event: events.RuleTargetInput.fromObject({ SomeParam: 'SomeValue' }),
retryAttempts: 2,
maxEventAge: Duration.hours(2),
},
));
Properties
attemptsoptionalnumberattemptsoptionalint | floatattemptsoptionalNumberAttemptsoptionaldoubleAttemptsoptional*float64#The number of times to attempt to retry, if the job fails.
Default: no retryStrategy is set
Valid values are 1–10.
deadLetterQueueoptionalIQueuedead_letter_queueoptionalIQueuedeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueue#The SQS queue to be used as deadLetterQueue. Check out the [considerations for using a dead-letter queue](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html#dlq-considerations).
Default: no dead-letter queue
notes
The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.
eventoptionalRuleTargetInputeventoptionalRuleTargetInputeventoptionalRuleTargetInputEventoptionalRuleTargetInputEventoptionalRuleTargetInput#The event to send to the Lambda.
Default: the entire EventBridge event
This will be the payload sent to the Lambda Function.
jobNameoptionalstringjob_nameoptionalstrjobNameoptionalStringJobNameoptionalstringJobNameoptional*string#The name of the submitted job.
Default: Automatically generated
maxEventAgeoptionalDurationmax_event_ageoptionalDurationmaxEventAgeoptionalDurationMaxEventAgeoptionalDurationMaxEventAgeoptionalDuration= Duration.hours(24)#The maximum age of a request that Lambda sends to a function for processing.
Minimum value of 60. Maximum value of 86400.
retryAttemptsoptionalnumberretry_attemptsoptionalint | floatretryAttemptsoptionalNumberRetryAttemptsoptionaldoubleRetryAttemptsoptional*float64= 185#The maximum number of times to retry when the function returns an error.
Minimum value of 0. Maximum value of 185.
The size of the array, if this is an array batch job.
Default: no arrayProperties are set
Valid values are integers between 2 and 10,000.