Skip to content

Resource: awsSchedulerSchedule

Provides an EventBridge Scheduler Schedule resource.

You can find out more about EventBridge Scheduler in the User Guide.

\~> Note: EventBridge was formerly known as CloudWatch Events. The functionality is identical.

Example Usage

Basic Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.schedulerSchedule.SchedulerSchedule(this, "example", {
  flexibleTimeWindow: {
    mode: "OFF",
  },
  groupName: "default",
  name: "my-schedule",
  scheduleExpression: "rate(1 hour)",
  target: {
    arn: "${aws_sqs_queue.example.arn}",
    roleArn: "${aws_iam_role.example.arn}",
  },
});

Universal Target

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.schedulerSchedule.SchedulerSchedule(this, "example", {
  flexibleTimeWindow: {
    mode: "OFF",
  },
  name: "my-schedule",
  scheduleExpression: "rate(1 hour)",
  target: {
    arn: "arn:aws:scheduler:::aws-sdk:sqs:sendMessage",
    input:
      '${jsonencode({\n      MessageBody = "Greetings, programs!"\n      QueueUrl    = aws_sqs_queue.example.url\n    })}',
    roleArn: "${aws_iam_role.example.arn}",
  },
});
const awsSqsQueueExample = new aws.sqsQueue.SqsQueue(this, "example_1", {});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsSqsQueueExample.overrideLogicalId("example");

Argument Reference

The following arguments are required:

  • flexibleTimeWindow - (Required) Configures a time window during which EventBridge Scheduler invokes the schedule. Detailed below.
  • scheduleExpression - (Required) Defines when the schedule runs. Read more in Schedule types on EventBridge Scheduler.
  • target - (Required) Configures the target of the schedule. Detailed below.

The following arguments are optional:

  • description - (Optional) Brief description of the schedule.
  • endDate - (Optional) The date, in UTC, before which the schedule can invoke its target. Depending on the schedule's recurrence expression, invocations might stop on, or before, the end date you specify. EventBridge Scheduler ignores the end date for one-time schedules. Example: 20300101T01:00:00Z.
  • groupName - (Optional, Forces new resource) Name of the schedule group to associate with this schedule. When omitted, the default schedule group is used.
  • kmsKeyArn - (Optional) ARN for the customer managed KMS key that EventBridge Scheduler will use to encrypt and decrypt your data.
  • name - (Optional, Forces new resource) Name of the schedule. If omitted, Terraform will assign a random, unique name. Conflicts with namePrefix.
  • namePrefix - (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts with name.
  • scheduleExpressionTimezone - (Optional) Timezone in which the scheduling expression is evaluated. Defaults to utc. Example: australia/sydney.
  • startDate - (Optional) The date, in UTC, after which the schedule can begin invoking its target. Depending on the schedule's recurrence expression, invocations might occur on, or after, the start date you specify. EventBridge Scheduler ignores the start date for one-time schedules. Example: 20300101T01:00:00Z.
  • state - (Optional) Specifies whether the schedule is enabled or disabled. One of: enabled (default), disabled.

flexible_time_window Configuration Block

  • maximumWindowInMinutes - (Optional) Maximum time window during which a schedule can be invoked. Ranges from 1 to 1440 minutes.
  • mode - (Required) Determines whether the schedule is invoked within a flexible time window. One of: off, flexible.

target Configuration Block

The following arguments are required:

The following arguments are optional:

  • deadLetterConfig - (Optional) Information about an Amazon SQS queue that EventBridge Scheduler uses as a dead-letter queue for your schedule. If specified, EventBridge Scheduler delivers failed events that could not be successfully delivered to a target to the queue. Detailed below.
  • ecsParameters - (Optional) Templated target type for the Amazon ECS runTask API operation. Detailed below.
  • eventbridgeParameters - (Optional) Templated target type for the EventBridge putEvents API operation. Detailed below.
  • input - (Optional) Text, or well-formed JSON, passed to the target. Read more in Universal target.
  • kinesisParameters - (Optional) Templated target type for the Amazon Kinesis putRecord API operation. Detailed below.
  • retryPolicy - (Optional) Information about the retry policy settings. Detailed below.
  • sagemakerPipelineParameters - (Optional) Templated target type for the Amazon SageMaker startPipelineExecution API operation. Detailed below.
  • sqsParameters - (Optional) The templated target type for the Amazon SQS sendMessage API operation. Detailed below.

dead_letter_config Configuration Block

  • arn - (Optional) ARN of the SQS queue specified as the destination for the dead-letter queue.

ecs_parameters Configuration Block

The following arguments are required:

  • taskDefinitionArn - (Required) ARN of the task definition to use.

The following arguments are optional:

  • capacityProviderStrategy - (Optional) Up to 6 capacity provider strategies to use for the task. Detailed below.
  • enableEcsManagedTags - (Optional) Specifies whether to enable Amazon ECS managed tags for the task. For more information, see Tagging Your Amazon ECS Resources in the Amazon ECS Developer Guide.
  • enableExecuteCommand - (Optional) Specifies whether to enable the execute command functionality for the containers in this task.
  • group - (Optional) Specifies an ECS task group for the task. At most 255 characters.
  • launchType - (Optional) Specifies the launch type on which your task is running. The launch type that you specify here must match one of the launch type (compatibilities) of the target task. One of: ec2, fargate, external.
  • networkConfiguration - (Optional) Configures the networking associated with the task. Detailed below.
  • placementConstraints - (Optional) A set of up to 10 placement constraints to use for the task. Detailed below.
  • placementStrategy - (Optional) A set of up to 5 placement strategies. Detailed below.
  • platformVersion - (Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 110.
  • propagateTags - (Optional) Specifies whether to propagate the tags from the task definition to the task. One of: TASK_DEFINITION.
  • referenceId - (Optional) Reference ID to use for the task.
  • tags - (Optional) The metadata that you apply to the task. Each tag consists of a key and an optional value. For more information, see runTask in the Amazon ECS API Reference.
  • taskCount - (Optional) The number of tasks to create. Ranges from 1 (default) to 10.
capacity_provider_strategy Configuration Block
  • base - (Optional) How many tasks, at a minimum, to run on the specified capacity provider. Only one capacity provider in a capacity provider strategy can have a base defined. Ranges from 0 (default) to 100000.
  • capacityProvider - (Required) Short name of the capacity provider.
  • weight - (Optional) Designates the relative percentage of the total number of tasks launched that should use the specified capacity provider. The weight value is taken into consideration after the base value, if defined, is satisfied. Ranges from from 0 to 1000.
network_configuration Configuration Block
  • assignPublicIp - (Optional) Specifies whether the task's elastic network interface receives a public IP address. This attribute is a boolean type, where true maps to enabled and false to disabled. You can specify true only when the launchType is set to fargate.
  • securityGroups - (Optional) Set of 1 to 5 Security Group ID-s to be associated with the task. These security groups must all be in the same VPC.
  • subnets - (Optional) Set of 1 to 16 subnets to be associated with the task. These subnets must all be in the same VPC.
placement_constraints Configuration Block
  • expression - (Optional) A cluster query language expression to apply to the constraint. You cannot specify an expression if the constraint type is distinctInstance. For more information, see Cluster query language in the Amazon ECS Developer Guide.
  • type - (Required) The type of constraint. One of: distinctInstance, memberOf.
placement_strategy Configuration Block
  • field - (Optional) The field to apply the placement strategy against.
  • type - (Required) The type of placement strategy. One of: random, spread, binpack.

eventbridge_parameters Configuration Block

  • detailType - (Required) Free-form string used to decide what fields to expect in the event detail. Up to 128 characters.
  • source - (Required) Source of the event.

kinesis_parameters Configuration Block

  • partitionKey - (Required) Specifies the shard to which EventBridge Scheduler sends the event. Up to 256 characters.

retry_policy Configuration Block

  • maximumEventAgeInSeconds - (Optional) Maximum amount of time, in seconds, to continue to make retry attempts. Ranges from 60 to 86400 (default).
  • maximumRetryAttempts - (Optional) Maximum number of retry attempts to make before the request fails. Ranges from 0 to 185 (default).

sagemaker_pipeline_parameters Configuration Block

  • pipelineParameter - (Optional) Set of up to 200 parameter names and values to use when executing the SageMaker Model Building Pipeline. Detailed below.
pipeline_parameter Configuration Block
  • name - (Required) Name of parameter to start execution of a SageMaker Model Building Pipeline.
  • value - (Required) Value of parameter to start execution of a SageMaker Model Building Pipeline.

sqs_parameters Configuration Block

  • messageGroupId - (Optional) FIFO message group ID to use as the target.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - Name of the schedule.
  • arn - ARN of the schedule.

Import

Schedules can be imported using the combination groupName/name. For example:

$ terraform import aws_scheduler_schedule.example my-schedule-group/my-schedule