How to set schedule of DataSync Task to "Not Scheduled" from AWS Lambda?

278 views Asked by At

The boto3 documentation seems to provide information on how to set the scheduling on a DataSync Task.

From the boto3 doc (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/datasync.html#DataSync.Client.update_task), the solution in that case is quite simple ->

response = client.update_task(
    TaskArn='string',
    Schedule={
        'ScheduleExpression': 'string'
    }
)

Here, value of ScheduleExpression can be any cron or rate job.

But when we need to turn off the scheduling (basically stopping the DataSync Task from running and copying any data without starting it manually from console/CLI or triggering it), I wasn't able to figure out how to format the code.

1

There are 1 answers

0
Ankan Das On

The simple solution is this ->

response = client.update_task(
    TaskArn='string',
    Schedule={
        'ScheduleExpression': ''
    }
)

This bit of code tells the DataSync Task to be updated without a scheduled expression, and it also deletes any existing schedule set on the Task.