class BatchJob
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Events.Targets.BatchJob |
Java | software.amazon.awscdk.services.events.targets.BatchJob |
Python | aws_cdk.aws_events_targets.BatchJob |
TypeScript (source) | @aws-cdk/aws-events-targets » BatchJob |
Implements
IRule
Use an AWS Batch Job / Queue as an event rule target.
Most likely the code will look something like this:
new BatchJob(jobQueue.jobQueueArn, jobQueue, jobDefinition.jobDefinitionArn, jobDefinition)
In the future this API will be improved to be fully typed
Example
import * as batch from '@aws-cdk/aws-batch';
import { ContainerImage } from '@aws-cdk/aws-ecs';
const jobQueue = new batch.JobQueue(this, 'MyQueue', {
computeEnvironments: [
{
computeEnvironment: new batch.ComputeEnvironment(this, 'ComputeEnvironment', {
managed: false,
}),
order: 1,
},
],
});
const jobDefinition = new batch.JobDefinition(this, 'MyJob', {
container: {
image: ContainerImage.fromRegistry('test-repo'),
},
});
const queue = new sqs.Queue(this, 'Queue');
const rule = new events.Rule(this, 'Rule', {
schedule: events.Schedule.rate(cdk.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: cdk.Duration.hours(2),
},
));
Initializer
new BatchJob(jobQueueArn: string, jobQueueScope: IConstruct, jobDefinitionArn: string, jobDefinitionScope: IConstruct, props?: BatchJobProps)
Parameters
- jobQueueArn
string
— The JobQueue arn. - jobQueueScope
IConstruct
— The JobQueue Resource. - jobDefinitionArn
string
— The jobDefinition arn. - jobDefinitionScope
IConstruct
— The JobQueue Resource. - props
Batch
Job Props
Methods
Name | Description |
---|---|
bind(rule, _id?) | Returns a RuleTarget that can be used to trigger queue this batch job as a result from an EventBridge event. |
bind(rule, _id?)
public bind(rule: IRule, _id?: string): RuleTargetConfig
Parameters
- rule
IRule
- _id
string
Returns
Returns a RuleTarget that can be used to trigger queue this batch job as a result from an EventBridge event.