Aws_scheduler_schedule

I am trying to use the aws_scheduler_schedule resource to stop /start an open search ingestion pipeline.

resource “aws_scheduler_schedule” “start” {
for_each = var.tenants
name = “{each.key}-pipeline-start" description = "Start schedule for {each.key} pipeline”
flexible_time_window {
mode = “OFF”
}
schedule_expression = “{each.key}.schedule_expression_start" target { input = jsonencode({ PipelineName= "alpha" }) arn = aws_osis_pipeline.this[each.key].***pipeline_arn*** # "aws_osis_pipeline.this[{each.key}.arn]”
role_arn = aws_iam_role.start_stop.arn
}
}

first issue ( not very important ) pipeline_arn is colored in red as if this attribute is not known
second issue when I try to create this resource I have the following error :
creating Amazon EventBridge Scheduler Schedule (search-pipeline-start): operation error Scheduler: CreateSchedule, https response error StatusCode: 400, RequestID: e96d7d24-ff5f-4b80-84b9-bd6cbc9d2fdb, ValidationException: osis is not a supported service for a target.

I’ve not really used EventBridge Scheduler, but looking at the documentation it seems that OSIS is not a supported templated target, so it falls under the universal target bucket. Thus the target ARN might be something like arn:aws:scheduler:::aws-sdk:osis:StartPipeline. You also need to provide input as a JSON since StartPipeline needs the pipeline name:

{
  "PipelineName": "MyPipeline"
}

Perhaps you can work backwards by first creating an schedule in the AWS Management Console, then look at the request parameters in the records CreateSchedule event in CloudTrail.

Might work?
Can you use reccurence? unsure to to translate it over. This just triggers a scaling at a certain time everyday. Will need to create an additional one to potentially stop/scale down what was created.

example:

resource "aws_autoscaling_schedule" "example" {
  scheduled_action_name  = "example"
  min_size               = 1
  max_size               = 3
  desired_capacity       = 3
  recurrence             = "0 11 * *"
  autoscaling_group_name = aws_autoscaling_group.example.name
}

Hi acwwat , you are right in fact it was the role that posed the problem , I didn’t use aws:scheduler:::aws-sdk:osis:StartPipeline . What I id is to create the schedule on the AWS and import it to find to right argumene . Here is the implementation ( I have a bunch of app thus the for each)
resource “aws_scheduler_schedule” “start” {
for_each = var.tenants
name = “{each.key}-pipeline-start" description = "Start schedule for {each.key} pipeline”
flexible_time_window {
mode = “OFF”
}
schedule_expression = each.value.schedule_expression_start
target {
input = jsonencode({
PipelineName = each.key
})
arn = “arn:aws:scheduler:::aws-sdk:osis:startPipeline”
role_arn = aws_iam_role.start_stop.arn

}
schedule_expression_timezone = var.schedule_expression_timezone

}