Task timed out when creating DataSync agent through boto3 in aws lambda

228 Views Asked by At

I'm trying to create a DataSync agent. When I use the console with the same parameters, it works fine and very quickly (a few seconds). However, if I want to create it by using the lambda function, the script returns a Task Timed Out Error of 900 seconds. (I increased the time limit to 15 mins since it gave the same error with lesser duration). I set Memory to 10240 MB. The lambda function is connected to the same VPC, and subnet, and has the same security group as the EC2 instance. Is there a way to create a data sync agent in the lambda function? I cannot believe that it lasts more than 15 minutes!

The error is as such:

Task timed out after 900.10 seconds

Code snippet:

def lambda_handler(event, _):
   agent_arn = client.create_agent(ActivationKey=event['activation_key'],
                                    VpcEndpointId=event['vpc_endpoint_id'], 
                                    SubnetArns=[event['subnet_arn']], 
                                    SecurityGroupArns=[event'sg_arn']])

    return {
        'agent_arn': agent_arn
    }
0

There are 0 best solutions below