简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM