Package: aws-cdk.aws-scheduler-targets-alpha
Amazon EventBridge Scheduler Construct Library---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 theSemantic Versioningmodel 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.Amazon EventBridge Scheduleris a feature from Amazon EventBridge
that allows you to create, run, and manage scheduled tasks at scale. With EventBridge Scheduler, you can schedule one-time or recurrently tens
of millions of tasks across many AWS services without provisioning or managing underlying infrastructure.This library contains integration classes for Amazon EventBridge Scheduler to call any
number of supported AWS Services.The following targets are supported:targets.LambdaInvoke:Invoke an AWS Lambda function)targets.StepFunctionsStartExecution:Start an AWS Step Functiontargets.CodeBuildStartBuild:Start a CodeBuild jobtargets.SqsSendMessage:Send a Message to an Amazon SQS Queuetargets.SnsPublish:Publish messages to an Amazon SNS topictargets.EventBridgePutEvents:Put Events on EventBridgetargets.InspectorStartAssessmentRun:Start an Amazon Inspector assessment runtargets.KinesisStreamPutRecord:Put a record to an Amazon Kinesis Data Streamstargets.KinesisDataFirehosePutRecord:Put a record to a Kinesis Data Firehosetargets.CodePipelineStartPipelineExecution:Start a CodePipeline executiontargets.SageMakerStartPipelineExecution:Start a SageMaker pipeline executionInvoke a Lambda functionUse theLambdaInvoketarget to invoke a lambda function.The code snippet below creates an event rule with a Lambda function as a target
called every hour by Event Bridge Scheduler with custom payload. You can optionally attach adead letter queue.importaws_cdk.aws_lambdaaslambda_fn=lambda_.Function(self,"MyFunc",runtime=lambda_.Runtime.NODEJS_LATEST,handler="index.handler",code=lambda_.Code.from_inline("exports.handler = handler.toString()"))dlq=sqs.Queue(self,"DLQ",queue_name="MyDLQ")target=targets.LambdaInvoke(fn,dead_letter_queue=dlq,max_event_age=Duration.minutes(1),retry_attempts=3,input=ScheduleTargetInput.from_object({"payload":"useful"}))schedule=Schedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.hours(1)),target=target)Start an AWS Step FunctionUse theStepFunctionsStartExecutiontarget to start a new execution on a StepFunction.The code snippet below creates an event rule with a Step Function as a target
called every hour by Event Bridge Scheduler with a custom payload.importaws_cdk.aws_stepfunctionsassfnimportaws_cdk.aws_stepfunctions_tasksastaskspayload={"Name":"MyParameter","Value":"🌥️"}put_parameter_step=tasks.CallAwsService(self,"PutParameter",service="ssm",action="putParameter",iam_resources=["*"],parameters={"Name.$":"$.Name","Value.$":"$.Value","Type":"String","Overwrite":True})state_machine=sfn.StateMachine(self,"StateMachine",definition_body=sfn.DefinitionBody.from_chainable(put_parameter_step))Schedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.hours(1)),target=targets.StepFunctionsStartExecution(state_machine,input=ScheduleTargetInput.from_object(payload)))Start a CodeBuild jobUse theCodeBuildStartBuildtarget to start a new build run on a CodeBuild project.The code snippet below creates an event rule with a CodeBuild project as target which is
called every hour by Event Bridge Scheduler.importaws_cdk.aws_codebuildascodebuild# project: codebuild.ProjectSchedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.minutes(60)),target=targets.CodeBuildStartBuild(project))Send A Message To SQS QueueUse theSqsSendMessagetarget to send a message to SQS Queue.The code snippet below creates an event rule with a SQS Queue as a target
called every hour by Event Bridge Scheduler with a custom payload.Contains themessageGroupIdto use when the target is a FIFO queue. If you specify
a FIFO queue as a target, the queue must have content-based deduplication enabled.payload="test"message_group_id="id"queue=sqs.Queue(self,"MyQueue",fifo=True,content_based_deduplication=True)target=targets.SqsSendMessage(queue,input=ScheduleTargetInput.from_text(payload),message_group_id=message_group_id)Schedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.minutes(1)),target=target)Publish messages to an Amazon SNS topicUse theSnsPublishtarget to publish messages to an Amazon SNS topic.The code snippets below create an event rule with a Amazon SNS topic as a target.
It's called every hour by Amazon Event Bridge Scheduler with custom payload.importaws_cdk.aws_snsassnstopic=sns.Topic(self,"Topic")payload={"message":"Hello scheduler!"}target=targets.SnsPublish(topic,input=ScheduleTargetInput.from_object(payload))Schedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.hours(1)),target=target)Send events to an EventBridge event busUse theEventBridgePutEventstarget to send events to an EventBridge event bus.The code snippet below creates an event rule with an EventBridge event bus as a target
called every hour by Event Bridge Scheduler with a custom event payload.importaws_cdk.aws_eventsaseventsevent_bus=events.EventBus(self,"EventBus",event_bus_name="DomainEvents")event_entry=targets.EventBridgePutEventsEntry(event_bus=event_bus,source="PetService",detail=ScheduleTargetInput.from_object({"Name":"Fluffy"}),detail_type="🐶")Schedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.hours(1)),target=targets.EventBridgePutEvents(event_entry))Start an Amazon Inspector assessment runUse theInspectorStartAssessmentRuntarget to start an Inspector assessment run.The code snippet below creates an event rule with an assessment template as target which is
called every hour by Event Bridge Scheduler.importaws_cdk.aws_inspectorasinspector# assessment_template: inspector.CfnAssessmentTemplateSchedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.minutes(60)),target=targets.InspectorStartAssessmentRun(assessment_template))Put a record to an Amazon Kinesis Data StreamsUse theKinesisStreamPutRecordtarget to put a record to an Amazon Kinesis Data Streams.The code snippet below creates an event rule with a stream as target which is
called every hour by Event Bridge Scheduler.importaws_cdk.aws_kinesisaskinesisstream=kinesis.Stream(self,"MyStream")Schedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.minutes(60)),target=targets.KinesisStreamPutRecord(stream,partition_key="key"))Put a record to a Kinesis Data FirehoseUse theKinesisDataFirehosePutRecordtarget to put a record to a Kinesis Data Firehose delivery stream.The code snippet below creates an event rule with a delivery stream as a target
called every hour by Event Bridge Scheduler with a custom payload.importaws_cdk.aws_kinesisfirehoseasfirehose# delivery_stream: firehose.CfnDeliveryStreampayload={"Data":"record"}Schedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.minutes(60)),target=targets.KinesisDataFirehosePutRecord(delivery_stream,input=ScheduleTargetInput.from_object(payload)))Start a CodePipeline executionUse theCodePipelineStartPipelineExecutiontarget to start a new execution for a CodePipeline pipeline.The code snippet below creates an event rule with a CodePipeline pipeline as target which is
called every hour by Event Bridge Scheduler.importaws_cdk.aws_codepipelineascodepipeline# pipeline: codepipeline.PipelineSchedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.minutes(60)),target=targets.CodePipelineStartPipelineExecution(pipeline))Start a SageMaker pipeline executionUse theSageMakerStartPipelineExecutiontarget to start a new execution for a SageMaker pipeline.The code snippet below creates an event rule with a SageMaker pipeline as target which is
called every hour by Event Bridge Scheduler.importaws_cdk.aws_sagemakerassagemaker# pipeline: sagemaker.IPipelineSchedule(self,"Schedule",schedule=ScheduleExpression.rate(Duration.minutes(60)),target=targets.SageMakerStartPipelineExecution(pipeline,pipeline_parameter_list=[targets.SageMakerPipelineParameter(name="parameter-name",value="parameter-value")]))