I am trying to implement a lambda function that creates a droplet. However, after the creation line of code, lambda stucks, and timeouts. In addition, in most of cases, it cannot create a droplet. The result is the same even I have extended the timeout range. Also, it means lots of billing from aws. I am running the same code in local python (in my laptop), there is no problem. What can I do? here is the code:

import digitalocean
manager = digitalocean.Manager(token="token")

my_droplets = manager.get_all_droplets()
for droplet in my_droplets:
    d = droplet.load()
    if d.name == 'mefJitsi3':

print('not found')

keys = manager.get_all_sshkeys()
droplet = digitalocean.Droplet(token="token",
                               region='fra1', # Amster
                               image='58038226', # Ubuntu 14.04 x64
                               size_slug='s-1vcpu-1gb',  # 512MB
                               ssh_keys=keys, #Automatic conversion
droplet.create() # code stucks here
edited by asb

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Looks like the issue could be in the Lambda execution environment or some limitations around running asynchronous calls. Might be worth checking out the local python debugging tools for Lambda: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging-python.html