简体   繁体   中英

AWS DataSync Lambda Automation

I am automating AWS Datasync task execution for EFS-EFS across different regions. I have written a lambda code in python and want to start the execution of datasync task through CloudWatch event cron expression.

    import boto3

    client = boto3.client('datasync', region_name='us-west-2')

    def lambda_handler(event,context):

    response = client.start_task_execution(
    TaskArn='arn:aws:datasync:us-west-2:7777777777:task/task-0ede5d4rd8a63338dfd8',

    OverrideOptions={
        'VerifyMode': 'POINT_IN_TIME_CONSISTENT'|'NONE',
        'Atime': 'NONE'|'BEST_EFFORT',
        'Mtime': 'NONE'|'PRESERVE',
        'Uid': 'NONE'|'INT_VALUE'|'NAME'|'BOTH',
        'Gid': 'NONE'|'INT_VALUE'|'NAME'|'BOTH',
        'PreserveDeletedFiles': 'PRESERVE'|'REMOVE',
        'PreserveDevices': 'NONE'|'PRESERVE',
        'PosixPermissions': 'NONE'|'BEST_EFFORT'|'PRESERVE',
        'BytesPerSecond': 123
    },
)

I am facing error on the above lambda code in python. Could any please help me correct the above code?

Datasync is no more available as a resource for boto3; it is a service in itself. You can use data sync using CLi or console to perform the migration

I know this is an old thread but I had a similar need and ended up using the below code in my lambda to trigger the datasync task to run. I'm using an S3 trigger to start the Lambda so that when I file is added to my bucket, it kicks off the datasync to a preconfigured task in Datasync.

import boto3

client = boto3.client('datasync', region_name='us-east-1')

def lambda_handler(event,context):
    response = client.start_task_execution(TaskArn='inserttaskarnhere')

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