Ankan Das
Ankan Das

Reputation: 298

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

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.

Upvotes: 0

Views: 364

Answers (1)

Ankan Das
Ankan Das

Reputation: 298

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.

Upvotes: 0

Related Questions