@task
def create_instance(nodetype, name, zone, existing_instance_id=None):
  env.nodetype = nodetype

  # Names must be unique across all node types.
  named_instances = ec2_utils.ListInstances(env.region, names=[name])
  if named_instances:
    assert len(named_instances) == 1, 'Multiple instances found with name %s' % name
    prev_id = named_instances[0].id
    assert existing_instance_id is not None and existing_instance_id == prev_id, \
      'Name %s already in use by instance %s' % (name, prev_id)
  assert name.startswith(nodetype), 'Instance name must start with %s' % nodetype

  instance_id, instance_hostname = setup_instance(zone, name, existing_instance_id=existing_instance_id)
  with settings(host_string=instance_hostname):
    deploy(new_instance=True)
Create a new instance. Specify NodeType,Name,AvailabilityZone,[id_to_resume].
dataset/ETHPy150Open viewfinderco/viewfinder/fabfile.py/create_instance