Amazon.Scheduler.Model.ValidationException: 'batch is not a supported service for a target.'

73 Views Asked by At

I am trying to submit a batch job based on a schedule, using Event bridge scheduler (not using Eventbridge rules because of the max limit of 300 it has)

But when I call the CreateScheduleAsync method with the batch config using .Net SDK, I get an error message saying batch is not supported as a target.

Targetting a batch job through scheduler is possible on the AWS console, So I am expecting it to work with the SDK as well.

This is the error message I get - "Amazon.Scheduler.Model.ValidationException: 'batch is not a supported service for a target.'"

Am i missing something or AWS SDK does not support batch jobs as targets, In that case what can be a proper alternative ?

            var schedulerClient = new AmazonSchedulerClient();
            var scheduleJobInput = new
            {
                JobDefinition = <jobDefinitionName>,
                JobName = <jobName>,
                JobQueue = <jobQueueName>,
                ContainerOverrides = new ContainerOverridesCustom
                {
                    Command = new List<string>() { "some test data" }
                },
                Timeout = new JobTimeoutCustom
                {
                    AttemptDurationSeconds = <timeout>
                }
            };

            var scheduleTimeWindow = new FlexibleTimeWindow
            {
                Mode = FlexibleTimeWindowMode.OFF
            };

            var invokeBatchTarget = new Amazon.Scheduler.Model.Target
            {
                Arn = <jobQueueName>,
                RoleArn = <roleArn>,
                Input = JsonConvert.SerializeObject(scheduleJobInput)
            };

            var createScheduleRequest = new CreateScheduleRequest
            {
                Name = <scheduler-name>,
                ScheduleExpression = "cron(0 12 * * ? *)",
                State = ScheduleState.ENABLED,
                Description = <scheduler-description>,
                FlexibleTimeWindow = scheduleTimeWindow,
                Target = invokeBatchTarget,
                GroupName = <scheduler-group-name>               
            };
            var createScheduleResponse = await schedulerClient.CreateScheduleAsync(createScheduleRequest); 

AWS .NET SDK and/or Package version used

AWSSDK.Scheduler- 3.7.300.16

Targeted .NET Platform

.NET 6.0

Operating System and version

Windows 10

0

There are 0 best solutions below