I'm working on a python lambda function, to request spot ec2 instances. I want to pass a script in UserData, such that i can do some file processing , say for the sake of this example copy files from one s3 to another, once done, would like to terminate the ec2 instance created. can someone provide sample script , maybe in python to achieve this.
def lambda_handler(event, context):
    ec2.request_spot_instances(
        SpotPrice='<-- max price for spot instance -->',
        InstanceCount=5,
        Type='one-time',
        LaunchSpecification={
            'ImageId': '<--- ami id ---> ',
            'InstanceType': '<-- instance type -->',
            'UserData': '',
            ...
        }
 )
