Skip to content

Instantly share code, notes, and snippets.

@kpavlovsky
Created October 28, 2019 10:56
Show Gist options
  • Save kpavlovsky/a8ea454acb2bc34ff999e44c647ed8df to your computer and use it in GitHub Desktop.
Save kpavlovsky/a8ea454acb2bc34ff999e44c647ed8df to your computer and use it in GitHub Desktop.
Create a Digital Ocean Droplet with Ubuntu 18.04 via Python 3 API
manager = digitalocean.Manager(token=user.digital_ocean_token)
images = manager.get_global_images()
image_id = None
for i in images:
if i.slug == 'ubuntu-18-04-x64':
image_id = i.id
if not image_id:
return "Server creation failed, could not find a suitable image"
droplet = digitalocean.Droplet(
token=user.digital_ocean_token,
name=server_name,
region='nyc1',
image=image_id,
ssh_keys=keys,
size="s-2vcpu-4gb",
backups=True)
droplet.create()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment