subcategory | layout | page_title | description |
---|---|---|---|
EventBridge Scheduler |
aws |
AWS: aws_scheduler_schedule |
Provides an EventBridge Scheduler Schedule resource. |
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.
resource "aws_scheduler_schedule" "example" {
name = "my-schedule"
group_name = "default"
flexible_time_window {
mode = "OFF"
}
schedule_expression = "rate(1 hour)"
target {
arn = aws_sqs_queue.example.arn
role_arn = aws_iam_role.example.arn
}
}
resource "aws_sqs_queue" "example" {}
resource "aws_scheduler_schedule" "example" {
name = "my-schedule"
flexible_time_window {
mode = "OFF"
}
schedule_expression = "rate(1 hour)"
target {
arn = "arn:aws:scheduler:::aws-sdk:sqs:sendMessage"
role_arn = aws_iam_role.example.arn
input = jsonencode({
MessageBody = "Greetings, programs!"
QueueUrl = aws_sqs_queue.example.url
})
}
}
The following arguments are required:
flexible_time_window
- (Required) Configures a time window during which EventBridge Scheduler invokes the schedule. Detailed below.schedule_expression
- (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.end_date
- (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:2030-01-01T01:00:00Z
.group_name
- (Optional, Forces new resource) Name of the schedule group to associate with this schedule. When omitted, thedefault
schedule group is used.kms_key_arn
- (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 withname_prefix
.name_prefix
- (Optional, Forces new resource) Creates a unique name beginning with the specified prefix. Conflicts withname
.schedule_expression_timezone
- (Optional) Timezone in which the scheduling expression is evaluated. Defaults toUTC
. Example:Australia/Sydney
.start_date
- (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:2030-01-01T01:00:00Z
.state
- (Optional) Specifies whether the schedule is enabled or disabled. One of:ENABLED
(default),DISABLED
.
maximum_window_in_minutes
- (Optional) Maximum time window during which a schedule can be invoked. Ranges from1
to1440
minutes.mode
- (Required) Determines whether the schedule is invoked within a flexible time window. One of:OFF
,FLEXIBLE
.
The following arguments are required:
arn
- (Required) ARN of the target of this schedule, such as a SQS queue or ECS cluster. For universal targets, this is a Service ARN specific to the target service.role_arn
- (Required) ARN of the IAM role that EventBridge Scheduler will use for this target when the schedule is invoked. Read more in Set up the execution role.
The following arguments are optional:
dead_letter_config
- (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.ecs_parameters
- (Optional) Templated target type for the Amazon ECSRunTask
API operation. Detailed below.eventbridge_parameters
- (Optional) Templated target type for the EventBridgePutEvents
API operation. Detailed below.input
- (Optional) Text, or well-formed JSON, passed to the target. Read more in Universal target.kinesis_parameters
- (Optional) Templated target type for the Amazon KinesisPutRecord
API operation. Detailed below.retry_policy
- (Optional) Information about the retry policy settings. Detailed below.sagemaker_pipeline_parameters
- (Optional) Templated target type for the Amazon SageMakerStartPipelineExecution
API operation. Detailed below.sqs_parameters
- (Optional) The templated target type for the Amazon SQSSendMessage
API operation. Detailed below.
arn
- (Required) ARN of the SQS queue specified as the destination for the dead-letter queue.
The following arguments are required:
task_definition_arn
- (Required) ARN of the task definition to use.
The following arguments are optional:
capacity_provider_strategy
- (Optional) Up to6
capacity provider strategies to use for the task. Detailed below.enable_ecs_managed_tags
- (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.enable_execute_command
- (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.launch_type
- (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
.network_configuration
- (Optional) Configures the networking associated with the task. Detailed below.placement_constraints
- (Optional) A set of up to 10 placement constraints to use for the task. Detailed below.placement_strategy
- (Optional) A set of up to 5 placement strategies. Detailed below.platform_version
- (Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as1.1.0
.propagate_tags
- (Optional) Specifies whether to propagate the tags from the task definition to the task. One of:TASK_DEFINITION
.reference_id
- (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, seeRunTask
in the Amazon ECS API Reference.task_count
- (Optional) The number of tasks to create. Ranges from1
(default) to10
.
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 from0
(default) to100000
.capacity_provider
- (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 from0
to1000
.
assign_public_ip
- (Optional) Specifies whether the task's elastic network interface receives a public IP address. This attribute is a boolean type, wheretrue
maps toENABLED
andfalse
toDISABLED
. You can specifytrue
only when thelaunch_type
is set toFARGATE
.security_groups
- (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.
expression
- (Optional) A cluster query language expression to apply to the constraint. You cannot specify an expression if the constraint type isdistinctInstance
. For more information, see Cluster query language in the Amazon ECS Developer Guide.type
- (Required) The type of constraint. One of:distinctInstance
,memberOf
.
field
- (Optional) The field to apply the placement strategy against.type
- (Required) The type of placement strategy. One of:random
,spread
,binpack
.
detail_type
- (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.
partition_key
- (Required) Specifies the shard to which EventBridge Scheduler sends the event. Up to 256 characters.
maximum_event_age_in_seconds
- (Optional) Maximum amount of time, in seconds, to continue to make retry attempts. Ranges from60
to86400
(default).maximum_retry_attempts
- (Optional) Maximum number of retry attempts to make before the request fails. Ranges from0
to185
(default).
pipeline_parameter
- (Optional) Set of up to 200 parameter names and values to use when executing the SageMaker Model Building Pipeline. Detailed below.
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.
message_group_id
- (Optional) FIFO message group ID to use as the target.
In addition to all arguments above, the following attributes are exported:
id
- Name of the schedule.arn
- ARN of the schedule.
Schedules can be imported using the combination group_name/name
. For example:
$ terraform import aws_scheduler_schedule.example my-schedule-group/my-schedule